/** * Called when the plan is aborted. */ public void aborted() { if(cc!=null) { cc.terminate(); } } }
/** * Create a new future. */ public TerminableDelegationFuture(ITerminableFuture<?> src) { src.addResultListener(new TerminableDelegationResultListener(this, src)); }
/** * Set the termination source. */ public void setTerminationSource(ITerminableFuture<?> src) { assert this.src==null; boolean mynotify; synchronized(this) { // Notify when someone has called terminate (notify is set) // src is set and not already notified this.src = src; mynotify = notify && !notified; notified = notified || mynotify; } if(mynotify) src.terminate(reason); if(storedinfos!=null) { for(Object info: storedinfos) { src.sendBackwardCommand(info); } storedinfos = null; } }
fut.addResultListener(new IResultListener<String>() fut.terminate();
/** * Send a backward command in direction of the source. * @param info The command info. */ public void sendBackwardCommand(Object info) { if(src!=null) { src.sendBackwardCommand(info); } else { if(storedinfos==null) storedinfos = new ArrayList<Object>(); storedinfos.add(info); } } }
/** * The body method is called on the * instantiated plan instance from the scheduler. */ @PlanBody public void body(SendRescueForce goal) { ISpaceObject disaster = goal.getDisaster(); IExtinguishFireService force = (IExtinguishFireService)goal.getRescueForce(); ef = force.extinguishFire(disaster.getId()); ef.get(); }
public void run() { Object tfut = rsms.getProcessingCall(cmdcallid); if(tfut!=null) { // System.out.println("terminated future afterwards"); ((ITerminableFuture<?>)tfut).sendBackwardCommand(info); } } });
/** * The body method is called on the * instantiated plan instance from the scheduler. */ @PlanBody public void body(SendRescueForce goal) { ISpaceObject disaster = goal.getDisaster(); IClearChemicalsService force = (IClearChemicalsService)goal.getRescueForce(); cc = force.clearChemicals(disaster.getId()); cc.get(); }
/** * Called when the plan is aborted. */ public void aborted() { if(ef!=null) { ef.terminate(); } } }
publishEvent(ChatEvent.TYPE_FILE, null, cid, fi); fut.addResultListener(new ExceptionDelegationResultListener<IOutputConnection, Void>(ret)
public void run() { Object tfut = rsms.getProcessingCall(cmdcallid); if(tfut!=null) { // System.out.println("terminated future afterwards"); ((ITerminableFuture<?>)tfut).sendBackwardCommand(info); } } });
/** * The body method is called on the * instantiated plan instance from the scheduler. */ @PlanBody public void body(SendRescueForce goal) { ISpaceObject disaster = (ISpaceObject)goal.getDisaster(); // System.out.println("treat victims for: "+disaster); ITreatVictimsService force = (ITreatVictimsService)goal.getRescueForce(); tv = force.treatVictims(disaster.getId()); tv.get(); // System.out.println("treat victims end for: "+disaster); }
public void intermediateResultAvailable(Void result) { fut.terminate(); } public void customResultAvailable(Collection<Void> result)
transfers2.put(fi.getId(), new Tuple3<TransferInfo, ITerminableFuture<IOutputConnection>, IConnection>(fi, fut, null)); publishEvent(ChatEvent.TYPE_FILE, null, cid, fi); fut.addResultListener(new ExceptionDelegationResultListener<IOutputConnection, Void>(ret)
((ITerminableFuture<?>)tfut).sendBackwardCommand(info);
/** * The body method is called on the * instantiated plan instance from the scheduler. */ public void body() { ISpaceObject disaster = (ISpaceObject)getParameter("disaster").getValue(); IClearChemicalsService force = (IClearChemicalsService)getParameter("rescueforce").getValue(); cc = force.clearChemicals(disaster.getId()); cc.get(Timeout.NONE); // hack??? clearing chemicals may take longer than default timeout }
/** * Terminate the future and supply a custom reason. */ public void terminate(Exception reason) { boolean mynotify; synchronized(this) { // Notify when src is set and not already notified // Remember to notify when src is not set and not already notified mynotify = src!=null && !notified; notify = src==null && !notified; notified = notified || mynotify; if(notify) this.reason = reason; } if(mynotify) src.terminate(reason); }
transfers2.put(fi.getId(), new Tuple3<TransferInfo, ITerminableFuture<IOutputConnection>, IConnection>(fi, fut, null)); publishEvent(ChatEvent.TYPE_FILE, null, cid, fi); fut.addResultListener(new ExceptionDelegationResultListener<IOutputConnection, Void>(ret)