Created
June 11, 2018 18:41
-
-
Save adamw/5b2297b9d327c894ad95f87c1d1fe863 to your computer and use it in GitHub Desktop.
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
def broadcast(connector: QueueConnector[Task]): Task[BroadcastResult] = { | |
def processMessages(inbox: MVar[BroadcastMessage], | |
consumers: Set[String => Task[Unit]]): Task[Unit] = // ... | |
def consumeForever(inbox: MVar[BroadcastMessage]): Task[Unit] = // ... | |
for { | |
inbox <- MVar.empty[BroadcastMessage] | |
f1 <- consumeForever(inbox).fork | |
f2 <- processMessages(inbox, Set()).fork | |
} yield BroadcastResult(inbox, f1.cancel *> f2.cancel) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment