How it works...
In this recipe, we covered how to develop CountDownLatch by leveraging Akka actors. We start by creating a CountDownLatch object, where you pass the count and, implicitly, an actor system. This object is responsible for instantiating the CountDownLatchActor class, creating Promise[Done], and returning a new instance of the CountDownLatch class. This instance is what we give to other resources to count down. It also provides an await method to block until the latch is open or a result value to signal that through an asynchronous instance of the type Future[Done].
In this particular example, we give the CountDownLatch instance to the 2 CountDownLatchWorker instances. These instances call countDown() once they are done in the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access