Skip to content

Instantly share code, notes, and snippets.

@kcleereman
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kcleereman/d729d47d80262961f1a6 to your computer and use it in GitHub Desktop.
Save kcleereman/d729d47d80262961f1a6 to your computer and use it in GitHub Desktop.
JobManager cleanup and the callback that invokes it
public class JobManagerImpl implements JobManager {
private final JobManager self = TypedActor.<JobManager>self();
private final Promise<String> completion;
public JobManager(Promise<String> completion) {
this.completion = completion;
completion.future().onComplete(new OnComplete<String>() {
@Override
public void onComplete(Throwable arg0, String arg1) {
self.cleanup();
}
}, TypedActor.dispatcher());
}
public void cleanup() {
if(completion.isCompleted()) {
immutable.batchManager().nextBatch();
jobQueue.clear();
for(ActorRef child : JavaConversions.asJavaIterable(TypedActor.context().children())) {
TypedActor.context().stop(child);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment