Created
September 15, 2014 21:36
-
-
Save rssh/51448fdd4163721d59c4 to your computer and use it in GitHub Desktop.
jdv_article8 (scala trait)
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
trait AsyncInput[T] | |
{ | |
def onReceive(acceptor: T=>()): Unit | |
def read: Future[T] = { | |
Promise p = Promise[T]() | |
onReceive(p.complete(_)) | |
p.future | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
val p = Promise[T]
onReceive(p.complete)