Created
December 25, 2017 12:50
-
-
Save qrilka/1f7cd7c2254b0e267de77d3c61542d43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Concurrent (threadDelay) | |
import Control.Concurrent.Async | |
import Control.Concurrent.Chan.Unagi.Bounded | |
import Control.Monad | |
import SlaveThread (fork) | |
main = do | |
(inCh, outCh) <- newChan 500000 | |
race_ (sender inCh) (receiver outCh) | |
sender ch = forever $ do | |
threadDelay 50 | |
_ <- tryWriteChan ch 42 | |
return () | |
receiver ch = forever $ do | |
x <- readChan ch | |
return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment