use of com.birbit.android.jobqueue.messaging.message.PublicQueryMessage in project android-priority-jobqueue by yigit.
the class JobManager method waitUntilConsumersAreFinished.
private void waitUntilConsumersAreFinished(boolean stop) {
assertNotInMainThread();
final CountDownLatch latch = new CountDownLatch(1);
JqLog.v("adding no consumers listener.");
jobManagerThread.consumerManager.addNoConsumersListener(new Runnable() {
@Override
public void run() {
JqLog.v("received no consumers callback");
latch.countDown();
jobManagerThread.consumerManager.removeNoConsumersListener(this);
}
});
if (stop) {
stop();
}
if (jobManagerThread.consumerManager.getWorkerCount() == 0) {
return;
}
try {
latch.await();
} catch (InterruptedException ignored) {
}
PublicQueryMessage pm = messageFactory.obtain(PublicQueryMessage.class);
pm.set(PublicQueryMessage.CLEAR, null);
new IntQueryFuture<>(jobManagerThread.callbackManager.messageQueue, pm).getSafe();
}
Aggregations