@Override public Set<Task<?>> getTasksWithTag(Object tag) { Set<Task<?>> result = tasksWithTagLiveOrNull(tag); if (result==null) return Collections.emptySet(); synchronized (result) { return Collections.unmodifiableSet(new LinkedHashSet<Task<?>>(result)); } }
private Set<Task<?>> tasksWithTagCreating(Object tag) { Preconditions.checkNotNull(tag); synchronized (tasksByTag) { Set<Task<?>> result = tasksWithTagLiveOrNull(tag); if (result==null) { result = Collections.synchronizedSet(new LinkedHashSet<Task<?>>()); tasksByTag.put(tag, result); } return result; } }
@Override public Set<Task<?>> getTasksWithAnyTag(Iterable<?> tags) { Set<Task<?>> result = new LinkedHashSet<Task<?>>(); Iterator<?> ti = tags.iterator(); while (ti.hasNext()) { Set<Task<?>> tasksForTag = tasksWithTagLiveOrNull(ti.next()); if (tasksForTag!=null) { synchronized (tasksForTag) { result.addAll(tasksForTag); } } } return Collections.unmodifiableSet(result); }
protected boolean deleteTaskNonRecursive(Task<?> task) { Set<?> tags = checkNotNull(task, "task").getTags(); for (Object tag : tags) { synchronized (tasksByTag) { Set<Task<?>> tasks = tasksWithTagLiveOrNull(tag); if (tasks != null) { tasks.remove(task); if (tasks.isEmpty()) { tasksByTag.remove(tag); } } } } Task<?> removed = tasksById.remove(task.getId()); incompleteTaskIds.remove(task.getId()); if (removed!=null && removed.isSubmitted() && !removed.isDone()) { log.warn("Deleting submitted task before completion: "+removed+"; this task will continue to run in the background outwith "+this+", but perhaps it should have been cancelled?"); } return removed != null; }
if (isTagIgnoredForGc(tag)) continue; Set<Task<?>> tasksWithTag = executionManager.tasksWithTagLiveOrNull(tag); if (tasksWithTag==null) continue; AtomicInteger overA = null;