Skip to content

Instantly share code, notes, and snippets.

@adamw
Last active June 7, 2019 10:52
Show Gist options
  • Save adamw/c71293bdd345ab4268b4027a15568490 to your computer and use it in GitHub Desktop.
Save adamw/c71293bdd345ab4268b4027a15568490 to your computer and use it in GitHub Desktop.
val cs1 = IO.contextShift(ec1)
val cs2 = IO.contextShift(ec2)
def run(name: String)(th: IO[_]): Unit = {
println(s"-- $name --")
th.unsafeRunSync()
println()
}
run("Shift") {
printThread *> IO.shift(ec1) *> printThread *> IO.shift(ec2) *> printThread
}
/*
Outputs:
-- Shift --
main
ec1-1-274064559
ec2-1-1945604815
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment