diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-12 06:34:19 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-12 06:34:19 +0400 |
commit | 8b005c4eb0f58db974c342efe0821240f39a6331 (patch) | |
tree | 85a32db63949ed1082a61100b71fcb830e1044e5 /exsamples | |
parent | 7f27eec9bf34a513f7a28072468706e8975ef552 (diff) |
+ Rename to await and yield.
Diffstat (limited to 'exsamples')
-rw-r--r-- | exsamples/Main.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/exsamples/Main.hs b/exsamples/Main.hs index 81958613..a5b865b0 100644 --- a/exsamples/Main.hs +++ b/exsamples/Main.hs | |||
@@ -1,3 +1,4 @@ | |||
1 | {-# LANGUAGE ViewPatterns #-} | ||
1 | module Main (main) where | 2 | module Main (main) where |
2 | 3 | ||
3 | import Control.Concurrent | 4 | import Control.Concurrent |
@@ -18,8 +19,15 @@ main = do | |||
18 | discover swarm $ do | 19 | discover swarm $ do |
19 | addr <- asks connectedPeerAddr | 20 | addr <- asks connectedPeerAddr |
20 | liftIO $ print $ "connected to" ++ show addr | 21 | liftIO $ print $ "connected to" ++ show addr |
21 | e <- awaitEvent | 22 | |
22 | liftIO $ print e | 23 | forever $ do |
23 | liftIO $ threadDelay (100 * 1000000) | 24 | e <- awaitEvent |
25 | case e of | ||
26 | Available bf | ||
27 | | Just m <- findMin bf -> yieldEvent (Want (BlockIx m 0 10)) | ||
28 | | otherwise -> return () | ||
29 | Want bix -> liftIO $ print bix | ||
30 | Fragment blk -> liftIO $ print (ppBlock blk) | ||
31 | |||
24 | 32 | ||
25 | print "Bye-bye! =_=" \ No newline at end of file | 33 | print "Bye-bye! =_=" \ No newline at end of file |