Skip to content

Instantly share code, notes, and snippets.

@lbialy
Last active August 25, 2023 14:36
Show Gist options
  • Save lbialy/37523c5e8cdc6bf099aee8d4ea9263ee to your computer and use it in GitHub Desktop.
Save lbialy/37523c5e8cdc6bf099aee8d4ea9263ee to your computer and use it in GitHub Desktop.
//> using scala "3.3.0"
import scala.concurrent.*, ExecutionContext.Implicits.global, duration.*
import scala.util.boundary, boundary.*
def runsOnAnotherThread(msg: String): Future[Unit] =
Future:
println(s"This: $msg runs on ${Thread.currentThread.getName}")
def runTest(): Future[String] =
boundary:
for
_ <- runsOnAnotherThread("first")
_ = break(Future.successful("after first"))
yield "after yield"
@main def main =
val fut = runTest()
Await.ready(fut, Duration.Inf)
println(fut)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment