Skip to content

Instantly share code, notes, and snippets.

@qrilka
Created December 25, 2017 12:50
Show Gist options
  • Save qrilka/1f7cd7c2254b0e267de77d3c61542d43 to your computer and use it in GitHub Desktop.
Save qrilka/1f7cd7c2254b0e267de77d3c61542d43 to your computer and use it in GitHub Desktop.
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