use of org.gradle.internal.resources.ResourceLockState in project gradle by gradle.
the class DefaultTaskExecutionPlan method executeWithTask.
@Override
public boolean executeWithTask(final WorkerLease workerLease, final Action<TaskInternal> taskExecution) {
final AtomicReference<TaskInfo> selected = new AtomicReference<TaskInfo>();
final AtomicBoolean workRemaining = new AtomicBoolean();
coordinationService.withStateLock(new Transformer<ResourceLockState.Disposition, ResourceLockState>() {
@Override
public ResourceLockState.Disposition transform(ResourceLockState resourceLockState) {
if (cancellationToken.isCancellationRequested()) {
if (abortExecution()) {
tasksCancelled = true;
}
}
workRemaining.set(workRemaining());
if (!workRemaining.get()) {
return FINISHED;
}
if (allProjectsLocked()) {
return RETRY;
}
try {
selected.set(selectNextTask(workerLease));
} catch (Throwable t) {
abortAllAndFail(t);
workRemaining.set(false);
}
if (selected.get() == null && workRemaining.get()) {
return RETRY;
} else {
return FINISHED;
}
}
});
TaskInfo selectedTask = selected.get();
execute(selectedTask, workerLease, taskExecution);
return workRemaining.get();
}
use of org.gradle.internal.resources.ResourceLockState in project gradle by gradle.
the class DefaultWorkerLeaseService method allLockedByCurrentThread.
private boolean allLockedByCurrentThread(final Iterable<? extends ResourceLock> locks) {
final MutableBoolean allLocked = new MutableBoolean();
coordinationService.withStateLock(new Transformer<ResourceLockState.Disposition, ResourceLockState>() {
@Override
public ResourceLockState.Disposition transform(ResourceLockState resourceLockState) {
allLocked.set(CollectionUtils.every(locks, new Spec<ResourceLock>() {
@Override
public boolean isSatisfiedBy(ResourceLock lock) {
return lock.isLockedByCurrentThread();
}
}));
return FINISHED;
}
});
return allLocked.get();
}
Aggregations