Skip to content

Instantly share code, notes, and snippets.

@rssh
Created September 15, 2014 21:36
Show Gist options
  • Save rssh/51448fdd4163721d59c4 to your computer and use it in GitHub Desktop.
Save rssh/51448fdd4163721d59c4 to your computer and use it in GitHub Desktop.
jdv_article8 (scala trait)
trait AsyncInput[T]
{
def onReceive(acceptor: T=>()): Unit
def read: Future[T] = {
Promise p = Promise[T]()
onReceive(p.complete(_))
p.future
}
}
@StefanGheorghiu
Copy link

val p = Promise[T]
onReceive(p.complete)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment