Commit 87920fe6 authored by simonmar's avatar simonmar
Browse files

[project @ 2005-11-30 12:25:20 by simonmar]

Add test for Control.Concurrent.STM.registerDelay
parent ba968ba3
......@@ -113,3 +113,4 @@ test('conc050', skip, compile_and_run, ['-package stm'])
test('conc051', normal, compile_and_run, [''])
test('conc052', normal, compile_and_run, ['-package stm'])
test('conc053', normal, compile_and_run, ['-package stm'])
-- !!! test threadDelay, Random, and QSemN.
-- Variation of conc023, testing STM timeouts instead of IO
import Random
import Control.Concurrent
import Control.Exception
import Control.Concurrent.STM
n = 5000 -- no. of threads
m = 3000 -- maximum delay
main = do
s <- newQSemN n
(is :: [Int]) <- sequence (take n (repeat (getStdRandom (randomR (1,m)))))
mapM (fork_sleep s) is
waitQSemN s n
fork_sleep s i = forkIO (do waitQSemN s 1
t <- registerDelay (i*1000)
atomically $ (readTVar t >>= check)
signalQSemN s 1)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment