Search in sources :

Example 6 with SafeMessageQueue

use of com.birbit.android.jobqueue.messaging.SafeMessageQueue in project android-priority-jobqueue by yigit.

the class ConsumerManager method addWorker.

private void addWorker() {
    JqLog.d("adding another consumer");
    Consumer consumer = new Consumer(jobManagerThread.messageQueue, new SafeMessageQueue(timer, factory, "consumer"), factory, timer);
    final Thread thread;
    if (threadFactory != null) {
        thread = threadFactory.newThread(consumer);
    } else {
        thread = new Thread(threadGroup, consumer, "job-queue-worker-" + UUID.randomUUID());
        thread.setPriority(threadPriority);
    }
    consumers.add(consumer);
    try {
        thread.start();
    } catch (InternalError error) {
        // process is already dying, no reason to crash for this (and hide the real crash)
        JqLog.e(error, "Cannot start a thread. Looks like app is shutting down." + "See issue #294 for details.");
    }
}
Also used : MessageQueueConsumer(com.birbit.android.jobqueue.messaging.MessageQueueConsumer) SafeMessageQueue(com.birbit.android.jobqueue.messaging.SafeMessageQueue)

Aggregations

MessageQueueConsumer (com.birbit.android.jobqueue.messaging.MessageQueueConsumer)6 SafeMessageQueue (com.birbit.android.jobqueue.messaging.SafeMessageQueue)6 Consumer (com.birbit.android.jobqueue.ConsumerManager.Consumer)4 PriorityMessageQueue (com.birbit.android.jobqueue.messaging.PriorityMessageQueue)4 Test (org.junit.Test)4 MessageFactory (com.birbit.android.jobqueue.messaging.MessageFactory)3 CommandMessage (com.birbit.android.jobqueue.messaging.message.CommandMessage)3 RunJobMessage (com.birbit.android.jobqueue.messaging.message.RunJobMessage)3 JobHolder (com.birbit.android.jobqueue.JobHolder)2 Message (com.birbit.android.jobqueue.messaging.Message)2 JobConsumerIdleMessage (com.birbit.android.jobqueue.messaging.message.JobConsumerIdleMessage)2 RunJobResultMessage (com.birbit.android.jobqueue.messaging.message.RunJobResultMessage)2 MockTimer (com.birbit.android.jobqueue.test.timer.MockTimer)1