Closed yruslan closed 7 months ago
Adding support of time.After() and time.Tick() can be helpful for implementing some GoLang patterns in Scala.
time.After()
time.Tick()
Here is more info about the API in Go: https://pkg.go.dev/time
Both the ticker and timeout can return java.time.Instant
java.time.Instant
An example code can look like:
import scala.concurrent.duration.{Duration, SECONDS, MILLISECONDS} import com.github.yruslan.channel._ val channel = Channel.make[Int] val ticker = TimeTickr(Duration(200, MILLISECONDS) val timeout = TimeAfter(Duration(2, SECONDS) select( channel .recver(n => { println(s"Received $n") }), ticker.recver(tickInstant => { println(s"Received $tickInstant") }), ticker .recver(timeoutInstant => { println(s"Received $timeoutInstant ") }) )
Describe the feature
Adding support of
time.After()
andtime.Tick()
can be helpful for implementing some GoLang patterns in Scala.Here is more info about the API in Go: https://pkg.go.dev/time
Both the ticker and timeout can return
java.time.Instant
An example code can look like: