forked from esoeylemez/rapid
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDevelMain.hs
More file actions
34 lines (27 loc) · 790 Bytes
/
DevelMain.hs
File metadata and controls
34 lines (27 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- |
-- Copyright: (c) 2016 Ertugrul Söylemez
-- License: BSD3
-- Maintainer: Ertugrul Söylemez <esz@posteo.de>
-- Stability: experimental
module DevelMain
( -- * Test module
update
)
where
import Control.Concurrent.STM
import Control.Monad
import Rapid
update :: IO ()
update =
rapid 0 $ \r -> do
mv1 <- createRef r "var1" newEmptyTMVarIO
mv2 <- createRef r "var2" newEmptyTMVarIO
start r "producer" $
mapM_ (atomically . putTMVar mv1) [0 :: Integer ..]
restart r "consumer" $
forever . atomically $ do
x <- takeTMVar mv1
putTMVar mv2 (x, "blubb")
-- For debugging the update action:
replicateM_ 3 $
atomically (takeTMVar mv2) >>= print