1 package org.simantics.db.impl.query;
3 import java.util.ArrayList;
4 import java.util.Collection;
6 import org.simantics.db.impl.query.QueryProcessor.SessionTask;
9 * Support class for queuing pending tasks to be executed when result gets ready
11 public class PendingTaskSupport {
13 private ArrayList<SessionTask> pendingTasks;
14 private IPending pending;
16 public PendingTaskSupport(IPending pending) {
17 this.pending = pending;
21 * We assume here that the associated IPending performs this atomically
22 * The caller is responsible for execution of the returned task after the critical section
24 public boolean executeWhenResultIsAvailable(SessionTask task) {
25 if(pending.isPending()) {
26 if(pendingTasks == null)
27 pendingTasks = new ArrayList<SessionTask>();
28 pendingTasks.add(task);
36 * We assume here that the associated IPending performs this atomically after changing the pending result
37 * The caller is responsible for execution of the returned task after the critical section
39 public Collection<SessionTask> executePending() {
40 ArrayList<SessionTask> ret = pendingTasks;