File: concasync.hs

package info (click to toggle)
haskell-async 2.2.5-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 144 kB
  • sloc: haskell: 889; makefile: 3
file content (13 lines) | stat: -rw-r--r-- 318 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
import Control.Concurrent.Async
import System.Environment
import Control.Monad
import Control.Concurrent

main = runInUnboundThread $ do
  [n] <- fmap (fmap read) getArgs
  replicateM_ n $ concurrently (return 1) (return 2)

concurrently' left right =
  withAsync left $ \a ->
  withAsync right $ \b ->
  waitBoth a b