Last active
April 2, 2023 19:06
-
-
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/4523166d5376ef181e14c34dd6053e686bb5204a
This file contains 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.2.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