|
Scala example source code file (ChanUsage.scala)
The ChanUsage.scala Scala example source codepackage scalaz package example package concurrent import scalaz._ import effect._ import concurrent._ import Chan._ import std.anyVal._ import syntax.equal._ object ChanUsage extends App { def forkIO(f: => IO[Unit])(implicit s: Strategy): IO[Unit] = IO { s(f.unsafePerformIO); () } def calc(chan: Chan[Int], a: Int) = chan.write((1 to a).sum) val io = for { chan <- newChan[Int] _ <- forkIO(calc(chan, 100)) _ <- forkIO(calc(chan, 200)) a <- chan.read b <- chan.read } yield a + b assert(io.unsafePerformIO === 25150) } Other Scala examples (source code examples)Here is a short list of links related to this Scala ChanUsage.scala source code file: |
... this post is sponsored by my books ... | |
![]() #1 New Release! |
![]() FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.