Skip to content

Add support for time.After() and time.Tick() #24

@yruslan

Description

@yruslan

Describe the feature

Adding support of time.After() and time.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:

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 ")
  })
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions