Last active
August 25, 2023 14:36
-
-
Save lbialy/37523c5e8cdc6bf099aee8d4ea9263ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> 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