Skip to content
Snippets Groups Projects
Commit 929a82ae authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 1998-07-27 12:38:33 by simonm]

Add a test for black hole behaviour, where a computation is shared
between threads.
parent d9716ab5
No related merge requests found
module Main where
import Concurrent
-- This test hopefully exercises the black hole code. The main thread
-- forks off another thread and starts on a large computation.
-- The child thread attempts to get the result of the same large
-- computation (and should get blocked doing so, because the parent
-- won't have evaluated it yet). When the result is available, the
-- child passes it back to the parent who prints it out.
test = sum [1..10000]
main = do
x <- newEmptyMVar
forkIO (if test > 0
then putMVar x test
else error "proc"
)
if test > 0 -- evaluate test
then do result <- takeMVar x
print result
else error "main"
50005000
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment