Skip to content

Instantly share code, notes, and snippets.

@djspiewak
Created July 31, 2014 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djspiewak/5118f7fd8d2bcd69ca07 to your computer and use it in GitHub Desktop.
Save djspiewak/5118f7fd8d2bcd69ca07 to your computer and use it in GitHub Desktop.
var closure = 1
val generator = Task {
if (closure > 5) {
throw Process.End
}
val back = closure
closure += 1
back
}
val source: Process[Task, Int] = Process eval generator repeat
val partitioned: Writer[Task, Int, Int] = source map {
case x if x % 2 == 0 => -\/(x)
case x if x % 2 == 1 => \/-(x)
}
val channel: Channel[Task, Int, String] = Process.eval(Task now ({ i: Int =>
Task delay {
Thread.sleep(100)
i.toString
}
})).repeat
partitioned.connectO(channel)(wye.boundedQueue(10)).runLog.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment