Last active
May 25, 2024 08:39
-
-
Save dacr/13ff195adf279798ed5dcc16da2a33ba to your computer and use it in GitHub Desktop.
scala-cli no issue with execution context when object encapsulation is used / published by https://github.com/dacr/code-examples-manager #79626ca3-e7a6-47f9-a5d2-a9c92aafec1e/ccd8ef02f6440b13509aa48203a71b4624871d02
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
// summary : scala-cli no issue with execution context when object encapsulation is used | |
// keywords : scala, scala-cli, issues, @testable | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : 79626ca3-e7a6-47f9-a5d2-a9c92aafec1e | |
// created-on : 2022-01-09T16:51:37+01:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
//> using scala "3.4.2" | |
// --------------------- | |
// snippet for scala-cli issue https://github.com/VirtusLab/scala-cli/issues/532 | |
// related issue : https://github.com/com-lihaoyi/Ammonite/issues/802 | |
// | |
// MORE UP TO DATE INFORMATION : https://github.com/VirtusLab/scala-cli/issues/1905 | |
// RELATED : https://github.com/VirtusLab/scala-cli/issues/1933 | |
import scala.concurrent.{Await, ExecutionContext, ExecutionContextExecutor, Future} | |
import scala.concurrent.duration.* | |
object Encapsulated: | |
implicit val ec: ExecutionContextExecutor = ExecutionContext.global | |
def run()= | |
val future = | |
for | |
message <- Future("Hello world") | |
_ <- Future(println(message)) | |
yield () | |
Await.ready(future, 5.second) | |
Encapsulated.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment