/** * The request is suspended * * @param suspendRequest */ public void suspend(Suspend suspendRequest) { if (suspendRequest.task != null) { WaitForTasksCompletion.waitFor(suspendRequest.task, this); } else { Invoker.invoke(this, suspendRequest.timeout); } }
public static <V> void waitFor(Future<V> task, final Invocation invocation) { if (task instanceof Promise) { Promise<V> smartFuture = (Promise<V>) task; smartFuture.onRedeem( new F.Action<F.Promise<V>>() { public void invoke(Promise<V> result) { executor.submit(invocation); } }); } else { synchronized (WaitForTasksCompletion.class) { if (instance == null) { instance = new WaitForTasksCompletion(); Logger.warn("Start WaitForTasksCompletion"); instance.start(); } instance.queue.put(task, invocation); } } }