Skip to content

Instantly share code, notes, and snippets.

@retronym
Created March 27, 2015 13:02
Show Gist options
  • Save retronym/1e495c48dbf04967c6c4 to your computer and use it in GitHub Desktop.
Save retronym/1e495c48dbf04967c6c4 to your computer and use it in GitHub Desktop.
scala> object Test {
| def main(args: Array[String]): Unit = {
| import scala.concurrent._
| import ExecutionContext.Implicits.global
| val source1 = Promise[Int]()
| val source2 = Promise[Int]()
|
| val done = Promise[Boolean]()
| val future2 = source2.completeWith(source1.future).future
| future2.onComplete {
| case _ => done.success(true)
| }
| source2.tryFailure(new TimeoutException)
| source1.success(123)
| import duration._
| assert(Await.result(done.future, 10.minutes))
| }
| }
defined object Test
scala>
scala> (1 to 1000) foreach {i => print("."); Test.main(null)}
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
scala> (1 to 1000) foreach {i => print("."); Test.main(null)}
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment