public T get() throws InterruptedException, ExecutionException { await(); Object result = this.result; if (failure) throw new ExecutionException((Throwable) result); return (T) result; }
public void run() { try { result = callable.call(); } catch (Throwable t) { JVMStabilityInspector.inspectThrowable(t); logger.warn("Uncaught exception on thread {}: {}", Thread.currentThread(), t); result = t; failure = true; } finally { signalAll(); onCompletion(); } }
public void maybeExecuteImmediately(Runnable command) { FutureTask<?> ft = newTaskFor(command, null); if (!takeWorkPermit(false)) { addTask(ft); } else { try { ft.run(); } finally { returnWorkPermit(); // we have to maintain our invariant of always scheduling after any work is performed // in this case in particular we are not processing the rest of the queue anyway, and so // the work permit may go wasted if we don't immediately attempt to spawn another worker maybeSchedule(); } } }
public void maybeExecuteImmediately(Runnable command) { FutureTask<?> ft = newTaskFor(command, null); if (!takeWorkPermit(false)) { addTask(ft); } else { try { ft.run(); } finally { returnWorkPermit(); // we have to maintain our invariant of always scheduling after any work is performed // in this case in particular we are not processing the rest of the queue anyway, and so // the work permit may go wasted if we don't immediately attempt to spawn another worker maybeSchedule(); } } }
public void maybeExecuteImmediately(Runnable command) { FutureTask<?> ft = newTaskFor(command, null); if (!takeWorkPermit(false)) { addTask(ft); } else { try { ft.run(); } finally { returnWorkPermit(); // we have to maintain our invariant of always scheduling after any work is performed // in this case in particular we are not processing the rest of the queue anyway, and so // the work permit may go wasted if we don't immediately attempt to spawn another worker maybeSchedule(); } } }
public void run() { try { result = callable.call(); } catch (Throwable t) { JVMStabilityInspector.inspectThrowable(t); logger.warn("Uncaught exception on thread {}: {}", Thread.currentThread(), t); result = t; failure = true; } finally { signalAll(); onCompletion(); } }
public void run() { try { result = callable.call(); } catch (Throwable t) { JVMStabilityInspector.inspectThrowable(t); logger.warn("Uncaught exception on thread {}: {}", Thread.currentThread(), t); result = t; failure = true; } finally { signalAll(); onCompletion(); } }
public void run() { ExecutorLocals old = ExecutorLocals.create(); ExecutorLocals.set(locals); try { super.run(); } finally { ExecutorLocals.set(old); } } }
public boolean isDone() { return isSignaled(); }
public boolean isDone() { return isSignaled(); }
public void run() { ExecutorLocals old = ExecutorLocals.create(); ExecutorLocals.set(locals); try { super.run(); } finally { ExecutorLocals.set(old); } } }
public boolean isDone() { return isSignaled(); }
protected <T> FutureTask<T> newTaskFor(Callable<T> callable) { if (isTracing()) { if (callable instanceof LocalSessionFutureTask) return (LocalSessionFutureTask<T>) callable; return new LocalSessionFutureTask<T>(callable, ExecutorLocals.create()); } if (callable instanceof FutureTask) return (FutureTask<T>) callable; return new FutureTask<>(callable); }
public void run() { ExecutorLocals old = ExecutorLocals.create(); ExecutorLocals.set(locals); try { super.run(); } finally { ExecutorLocals.set(old); } } }
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { if (!await(timeout, unit)) throw new TimeoutException(); Object result = this.result; if (failure) throw new ExecutionException((Throwable) result); return (T) result; } }
protected <T> FutureTask<T> newTaskFor(Runnable runnable, T result, ExecutorLocals locals) { if (locals != null) { if (runnable instanceof LocalSessionFutureTask) return (LocalSessionFutureTask<T>) runnable; return new LocalSessionFutureTask<T>(runnable, result, locals); } if (runnable instanceof FutureTask) return (FutureTask<T>) runnable; return new FutureTask<>(runnable, result); }
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { if (!await(timeout, unit)) throw new TimeoutException(); Object result = this.result; if (failure) throw new ExecutionException((Throwable) result); return (T) result; } }
public T get() throws InterruptedException, ExecutionException { await(); Object result = this.result; if (failure) throw new ExecutionException((Throwable) result); return (T) result; }
protected <T> FutureTask<T> newTaskFor(Callable<T> callable) { if (isTracing()) { if (callable instanceof LocalSessionFutureTask) return (LocalSessionFutureTask<T>) callable; return new LocalSessionFutureTask<T>(callable, ExecutorLocals.create()); } if (callable instanceof FutureTask) return (FutureTask<T>) callable; return new FutureTask<>(callable); }
protected <T> FutureTask<T> newTaskFor(Runnable runnable, T result, ExecutorLocals locals) { if (locals != null) { if (runnable instanceof LocalSessionFutureTask) return (LocalSessionFutureTask<T>) runnable; return new LocalSessionFutureTask<T>(runnable, result, locals); } if (runnable instanceof FutureTask) return (FutureTask<T>) runnable; return new FutureTask<>(runnable, result); }