kopia lustrzana https://github.com/ryukoposting/Signal-Android
Move the Job#onSubmit call to be outside of the JobController lock.
rodzic
6e8f3d1e71
commit
81fc99724d
|
@ -80,7 +80,8 @@ class JobController {
|
|||
}
|
||||
|
||||
@WorkerThread
|
||||
synchronized void submitNewJobChain(@NonNull List<List<Job>> chain) {
|
||||
void submitNewJobChain(@NonNull List<List<Job>> chain) {
|
||||
synchronized (this) {
|
||||
chain = Stream.of(chain).filterNot(List::isEmpty).toList();
|
||||
|
||||
if (chain.isEmpty()) {
|
||||
|
@ -96,15 +97,22 @@ class JobController {
|
|||
}
|
||||
|
||||
insertJobChain(chain);
|
||||
triggerOnSubmit(chain);
|
||||
notifyAll();
|
||||
scheduleJobs(chain.get(0));
|
||||
}
|
||||
|
||||
// We have no control over what happens in jobs' onSubmit method, so we drop our lock to reduce the possibility of a deadlock
|
||||
triggerOnSubmit(chain);
|
||||
|
||||
synchronized (this) {
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
synchronized void submitJobWithExistingDependencies(@NonNull Job job, @NonNull Collection<String> dependsOn, @Nullable String dependsOnQueue) {
|
||||
void submitJobWithExistingDependencies(@NonNull Job job, @NonNull Collection<String> dependsOn, @Nullable String dependsOnQueue) {
|
||||
List<List<Job>> chain = Collections.singletonList(Collections.singletonList(job));
|
||||
|
||||
synchronized (this) {
|
||||
if (chainExceedsMaximumInstances(chain)) {
|
||||
jobTracker.onStateChange(job, JobTracker.JobState.IGNORED);
|
||||
Log.w(TAG, JobLogger.format(job, "Already at the max instance count. Factory limit: " + job.getParameters().getMaxInstancesForFactory() + ", Queue limit: " + job.getParameters().getMaxInstancesForQueue() + ". Skipping."));
|
||||
|
@ -138,9 +146,15 @@ class JobController {
|
|||
jobStorage.insertJobs(Collections.singletonList(fullSpec));
|
||||
|
||||
scheduleJobs(Collections.singletonList(job));
|
||||
}
|
||||
|
||||
// We have no control over what happens in jobs' onSubmit method, so we drop our lock to reduce the possibility of a deadlock
|
||||
triggerOnSubmit(chain);
|
||||
|
||||
synchronized (this) {
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
synchronized void cancelJob(@NonNull String id) {
|
||||
|
|
Ładowanie…
Reference in New Issue