Search in sources :

Example 1 with MarkerJob

use of org.thoughtcrime.securesms.jobs.MarkerJob in project Signal-Android by signalapp.

the class RestStrategy method blockUntilQueueDrained.

private static long blockUntilQueueDrained(@NonNull String queue, long timeoutMs) {
    long startTime = System.currentTimeMillis();
    final JobManager jobManager = ApplicationDependencies.getJobManager();
    final MarkerJob markerJob = new MarkerJob(queue);
    Optional<JobTracker.JobState> jobState = jobManager.runSynchronously(markerJob, timeoutMs);
    if (!jobState.isPresent()) {
        Log.w(TAG, "Timed out waiting for " + queue + " job(s) to finish!");
    }
    long endTime = System.currentTimeMillis();
    long duration = endTime - startTime;
    Log.d(TAG, "Waited " + duration + " ms for the " + queue + " job(s) to finish.");
    return timeoutMs - duration;
}
Also used : JobManager(org.thoughtcrime.securesms.jobmanager.JobManager) MarkerJob(org.thoughtcrime.securesms.jobs.MarkerJob)

Example 2 with MarkerJob

use of org.thoughtcrime.securesms.jobs.MarkerJob in project Signal-Android by signalapp.

the class MessageRetrievalStrategy method blockUntilQueueDrained.

protected static void blockUntilQueueDrained(@NonNull String tag, @NonNull String queue, long timeoutMs) {
    long startTime = System.currentTimeMillis();
    final JobManager jobManager = ApplicationDependencies.getJobManager();
    final MarkerJob markerJob = new MarkerJob(queue);
    Optional<JobTracker.JobState> jobState = jobManager.runSynchronously(markerJob, timeoutMs);
    if (!jobState.isPresent()) {
        Log.w(tag, "Timed out waiting for " + queue + " job(s) to finish!");
    }
    long endTime = System.currentTimeMillis();
    long duration = endTime - startTime;
    Log.d(tag, "Waited " + duration + " ms for the " + queue + " job(s) to finish.");
}
Also used : JobManager(org.thoughtcrime.securesms.jobmanager.JobManager) MarkerJob(org.thoughtcrime.securesms.jobs.MarkerJob)

Example 3 with MarkerJob

use of org.thoughtcrime.securesms.jobs.MarkerJob in project Signal-Android by WhisperSystems.

the class MessageRetrievalStrategy method blockUntilQueueDrained.

protected static void blockUntilQueueDrained(@NonNull String tag, @NonNull String queue, long timeoutMs) {
    long startTime = System.currentTimeMillis();
    final JobManager jobManager = ApplicationDependencies.getJobManager();
    final MarkerJob markerJob = new MarkerJob(queue);
    Optional<JobTracker.JobState> jobState = jobManager.runSynchronously(markerJob, timeoutMs);
    if (!jobState.isPresent()) {
        Log.w(tag, "Timed out waiting for " + queue + " job(s) to finish!");
    }
    long endTime = System.currentTimeMillis();
    long duration = endTime - startTime;
    Log.d(tag, "Waited " + duration + " ms for the " + queue + " job(s) to finish.");
}
Also used : JobManager(org.thoughtcrime.securesms.jobmanager.JobManager) MarkerJob(org.thoughtcrime.securesms.jobs.MarkerJob)

Example 4 with MarkerJob

use of org.thoughtcrime.securesms.jobs.MarkerJob in project Signal-Android by WhisperSystems.

the class RestStrategy method blockUntilQueueDrained.

private static long blockUntilQueueDrained(@NonNull String queue, long timeoutMs) {
    long startTime = System.currentTimeMillis();
    final JobManager jobManager = ApplicationDependencies.getJobManager();
    final MarkerJob markerJob = new MarkerJob(queue);
    Optional<JobTracker.JobState> jobState = jobManager.runSynchronously(markerJob, timeoutMs);
    if (!jobState.isPresent()) {
        Log.w(TAG, "Timed out waiting for " + queue + " job(s) to finish!");
    }
    long endTime = System.currentTimeMillis();
    long duration = endTime - startTime;
    Log.d(TAG, "Waited " + duration + " ms for the " + queue + " job(s) to finish.");
    return timeoutMs - duration;
}
Also used : JobManager(org.thoughtcrime.securesms.jobmanager.JobManager) MarkerJob(org.thoughtcrime.securesms.jobs.MarkerJob)

Aggregations

JobManager (org.thoughtcrime.securesms.jobmanager.JobManager)4 MarkerJob (org.thoughtcrime.securesms.jobs.MarkerJob)4