/** * Blocks until a result is available, or timeout milliseconds have elapsed * @param timeout in ms * @return An object * @throws TimeoutException If a timeout occurred (implies that timeout > 0) */ public T getResultWithTimeout(long timeout) throws TimeoutException { return _getResultWithTimeout(timeout); }
public T getResultWithTimeout(long timeout, boolean reset) throws TimeoutException { if(!reset) return _getResultWithTimeout(timeout); // the lock is acquired because we want to get the result and reset the promise in the same lock scope; if we had // to re-acquire the lock for reset(), some other thread could possibly set a new result before reset() is called ! lock.lock(); try { return _getResultWithTimeout(timeout); } finally { reset(); lock.unlock(); } }
/** * Blocks until a result is available, or timeout milliseconds have elapsed * @param timeout in ms * @return An object * @throws TimeoutException If a timeout occurred (implies that timeout > 0) */ public T getResultWithTimeout(long timeout) throws TimeoutException { return _getResultWithTimeout(timeout); }
/** * Blocks until a result is available, or timeout milliseconds have elapsed * @param timeout * @return An object * @throws TimeoutException If a timeout occurred (implies that timeout > 0) */ public Object getResultWithTimeout(long timeout) throws TimeoutException { synchronized(this) { try { return _getResultWithTimeout(timeout); } finally { notifyAll(); } } }
public T getResultWithTimeout(long timeout, boolean reset) throws TimeoutException { if(!reset) return _getResultWithTimeout(timeout); // the lock is acquired because we want to get the result and reset the promise in the same lock scope; if we had // to re-acquire the lock for reset(), some other thread could possibly set a new result before reset() is called ! lock.lock(); try { return _getResultWithTimeout(timeout); } finally { reset(); lock.unlock(); } }