-
- }
-
- @Override
- public String toString() {
- if(isDiscarded()) return "DISCARDED " + request.toString();
- else if(isExcepted()) return request.toString() + " " + getResult();
- else return request.toString() + " " + statusOrException;
- }
+
+ }
+
+ @Override
+ public String toString() {
+ if (isDiscarded())
+ return "DISCARDED " + id.toString();
+ else if (isExcepted())
+ return id.toString() + " " + getResult();
+ else
+ return id.toString() + " " + statusOrException;
+ }
+
+ @Override
+ public void execute(AsyncReadGraph graph, T result) {
+ Collection<SessionTask> tasks = null;
+ synchronized(this) {
+ setResult(result);
+ setReady();
+ if(pendingTaskSupport != null)
+ tasks = pendingTaskSupport.executePending();
+ }
+ if(tasks != null)
+ for(SessionTask task : tasks)
+ ((ReadGraphImpl)graph).processor.scheduleNow(task);
+ }
+
+ @Override
+ public synchronized void exception(AsyncReadGraph graph, Throwable throwable) {
+ Collection<SessionTask> tasks = null;
+ synchronized(this) {
+ except(throwable);
+ if(pendingTaskSupport != null)
+ tasks = pendingTaskSupport.executePending();
+ }
+ if(tasks != null)
+ for(SessionTask task : tasks)
+ ((ReadGraphImpl)graph).processor.scheduleNow(task);
+ }
+
+ public void executeWhenResultIsAvailable(QueryProcessor processor, SessionTask task) {
+ boolean ready = false;
+ synchronized(this) {
+ if(pendingTaskSupport == null)
+ pendingTaskSupport = new PendingTaskSupport(this);
+ ready = pendingTaskSupport.executeWhenResultIsAvailable(task);
+ }
+ if(ready) {
+ processor.scheduleNow(task);
+ }
+ }
+
+ @Override
+ public String classId() {
+ return null;
+ }