|
Akka/Scala example source code file (Watcher.java)
The Watcher.java Akka example source codepackage docs.io.japi; import java.util.concurrent.CountDownLatch; import akka.actor.ActorRef; import akka.actor.Terminated; import akka.actor.UntypedActor; public class Watcher extends UntypedActor { static public class Watch { final ActorRef target; public Watch(ActorRef target) { this.target = target; } } final CountDownLatch latch; public Watcher(CountDownLatch latch) { this.latch = latch; } @Override public void onReceive(Object msg) throws Exception { if (msg instanceof Watch) { getContext().watch(((Watch) msg).target); } else if (msg instanceof Terminated) { latch.countDown(); if (latch.getCount() == 0) getContext().stop(getSelf()); } } } Other Akka source code examplesHere is a short list of links related to this Akka Watcher.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.