var num =0
var num2 = 3333
val p2 = Process.eval {
Thread.sleep(10000)
Task.delay {
Thread.sleep(10000)
num2 = num2 + 1
s"hi ${num2}"
}
}.repeat.take(15)
//p2: scalaz.stream.Process[[x]scalaz.concurrent.Task[x],String] =
// Await(scalaz.concurrent.Task@5a554f1c,
//<function1>,Halt(scalaz.stream.Process$End$),Halt(scalaz.stream.Process$End$))
val p1 = Process.eval {
Thread.sleep(2000)
Task.delay {
Thread.sleep(2000)
num = num + 1
s"hi $num"
}
}.repeat.take(15)
//p1: scalaz.stream.Process[[x]scalaz.concurrent.Task[x],String] =
// Await(scalaz.concurrent.Task@7a54e904,
// <function1>,Halt(scalaz.stream.Process$End$),Halt(scalaz.stream.Process$End$))
// this interleaves them and I get disjunctions showing me their order
(p1 either p2).map(println).run.run
// this gives me the strings that are interleaved
(p1 interleave p2).map(println).run.run
How do you get a Process that is the combination of the 2 Processes but just in whatever order they arrive (meaning if the left goes twice before the right, that's ok, give the left twice and then when the right arrives emit it afterwards)?
I'm looking for the one with the shorter sleep to occur more frequently and see it come out multiple times before the slower process. Thanks in advance for anyone taking the time to read this, and especially to those who can share some insight.