本文整理了Java中java.util.concurrent.TimeoutException.<init>()
方法的一些代码示例,展示了TimeoutException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimeoutException.<init>()
方法的具体详情如下:
包路径:java.util.concurrent.TimeoutException
类名称:TimeoutException
方法名:<init>
[英]Constructs a TimeoutException with no specified detail message.
[中]构造没有指定详细信息的TimeoutException。
代码示例来源:origin: neo4j/neo4j
@Override
public T get( long timeout, TimeUnit unit ) throws InterruptedException, TimeoutException
{
if ( !guardedByLatch.await( timeout, unit ) )
{
throw new TimeoutException( jobDescription + " didn't complete within " +
timeout + " " + unit );
}
return supplier.get();
}
};
代码示例来源:origin: apache/kafka
R await(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
long startMs = System.currentTimeMillis();
long waitTimeMs = unit.toMillis(timeout);
long delta = 0;
synchronized (this) {
while (true) {
if (exception != null)
wrapAndThrow(exception);
if (done)
return value;
if (delta >= waitTimeMs) {
throw new TimeoutException();
}
this.wait(waitTimeMs - delta);
delta = System.currentTimeMillis() - startMs;
}
}
}
}
代码示例来源:origin: apache/avro
@Override
public T get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
if (latch.await(timeout, unit)) {
if (error != null) {
throw new ExecutionException(error);
}
return result;
} else {
throw new TimeoutException();
}
}
代码示例来源:origin: apache/hbase
@Override
public byte[] get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
if (hasResult) {
return result;
}
try {
result = waitForProcedureToComplete(procExec, proc, unit.toMillis(timeout));
hasResult = true;
return result;
} catch (TimeoutIOException e) {
throw new TimeoutException(e.getMessage());
} catch (Exception e) {
throw new ExecutionException(e);
}
}
}
代码示例来源:origin: apache/activemq
@Override
public BrokerInfo get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
try {
if (info == null) {
long deadline = System.currentTimeMillis() + unit.toMillis(timeout);
while (!disposed.get() || System.currentTimeMillis() - deadline < 0) {
if (slot.await(1, TimeUnit.MILLISECONDS)) {
break;
}
}
if (info == null) {
throw new TimeoutException();
}
}
return info;
} catch (InterruptedException e) {
throw new InterruptedException("Interrupted.");
}
}
代码示例来源:origin: mcxiaoke/android-volley
private synchronized T doGet(Long timeoutMs)
throws InterruptedException, ExecutionException, TimeoutException {
if (mException != null) {
throw new ExecutionException(mException);
}
if (mResultReceived) {
return mResult;
}
if (timeoutMs == null) {
wait(0);
} else if (timeoutMs > 0) {
wait(timeoutMs);
}
if (mException != null) {
throw new ExecutionException(mException);
}
if (!mResultReceived) {
throw new TimeoutException();
}
return mResult;
}
代码示例来源:origin: google/ExoPlayer
/**
* Blocks the current thread until the action schedule finished. This does not release the test
* runner and the test must still call {@link #blockUntilEnded(long)}.
*
* @param timeoutMs The maximum time to wait for the action schedule to finish.
* @return This test runner.
* @throws TimeoutException If the action schedule did not finish within the specified timeout.
* @throws InterruptedException If the test thread gets interrupted while waiting.
*/
public ExoPlayerTestRunner blockUntilActionScheduleFinished(long timeoutMs)
throws TimeoutException, InterruptedException {
if (!actionScheduleFinishedCountDownLatch.await(timeoutMs, TimeUnit.MILLISECONDS)) {
throw new TimeoutException("Test playback timed out waiting for action schedule to finish.");
}
return this;
}
代码示例来源:origin: neo4j/neo4j
@Override
public Integer get( long timeout, TimeUnit unit ) throws InterruptedException, TimeoutException
{
long end = System.currentTimeMillis() + unit.toMillis( timeout );
while ( System.currentTimeMillis() < end )
{
Integer result = tryGetExitValue( process );
if ( result != null )
{
return result;
}
Thread.sleep( 10 );
}
throw new TimeoutException( "Process '" + process + "' didn't exit within " + timeout + " " + unit );
}
};
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public T get(long timeout, TimeUnit unit) throws ExecutionException, TimeoutException {
A.ensure(timeout >= 0, "timeout >= 0");
A.notNull(unit, "unit != null");
try {
T res = fut.get(unit.toMillis(timeout));
if (fut.isCancelled())
throw new CancellationException("Task was cancelled: " + fut);
return res;
}
catch (IgniteFutureTimeoutCheckedException e) {
TimeoutException e2 = new TimeoutException();
e2.initCause(e);
throw e2;
}
catch (ComputeTaskTimeoutCheckedException e) {
throw new ExecutionException("Task execution timed out during waiting for task result: " + fut, e);
}
catch (IgniteCheckedException e) {
// Task cancellation may cause throwing exception.
if (fut.isCancelled()) {
RuntimeException ex = new CancellationException("Task was cancelled: " + fut);
ex.initCause(e);
throw ex;
}
throw new ExecutionException("Failed to get task result.", e);
}
}
}
代码示例来源:origin: pentaho/mondrian
public V get(long timeout, TimeUnit unit)
throws ExecutionException, InterruptedException, TimeoutException
{
// Wait for a put, fail or cancel
if (!dataGate.await(timeout, unit)) {
throw new TimeoutException();
}
// Now a put, fail or cancel has occurred, state does not change; we
// don't need even a read lock.
if (throwable != null) {
throw new ExecutionException(throwable);
}
return value;
}
代码示例来源:origin: com.netflix.rxjava/rxjava-core
@Override
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
if (finished.await(timeout, unit)) {
return getValue();
} else {
throw new TimeoutException("Timed out after " + unit.toMillis(timeout) + "ms waiting for underlying Observable.");
}
}
代码示例来源:origin: chentao0707/SimplifyReader
private synchronized T doGet(Long timeoutMs)
throws InterruptedException, ExecutionException, TimeoutException {
if (mException != null) {
throw new ExecutionException(mException);
}
if (mResultReceived) {
return mResult;
}
if (timeoutMs == null) {
wait(0);
} else if (timeoutMs > 0) {
wait(timeoutMs);
}
if (mException != null) {
throw new ExecutionException(mException);
}
if (!mResultReceived) {
throw new TimeoutException();
}
return mResult;
}
代码示例来源:origin: Atmosphere/atmosphere
@Override
public E get(long l, TimeUnit tu) throws InterruptedException, ExecutionException, TimeoutException {
if (innerFuture != null) {
return (E) innerFuture.get(l, tu);
}
boolean isSuccessful = latch.await(l, tu);
if (!isSuccessful) {
throw new TimeoutException();
}
return msg;
}
}
代码示例来源:origin: springside/springside4
@Override
public synchronized T get(final long timeout, final TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
Validate.notNull(unit, "Time unit");
final long msecs = unit.toMillis(timeout);
final long startTime = (msecs <= 0) ? 0 : System.currentTimeMillis();
long waitTime = msecs;
if (this.completed) {
return getResult();
} else if (waitTime <= 0) {
throw new TimeoutException();
} else {
for (;;) {
wait(waitTime);
if (this.completed) {
return getResult();
} else {
waitTime = msecs - (System.currentTimeMillis() - startTime);
if (waitTime <= 0) {
throw new TimeoutException();
}
}
}
}
}
代码示例来源:origin: h2oai/h2o-2
if ((ms = TimeUnit.NANOSECONDS.toMillis(ns)) > 0L &&
U.compareAndSwapInt(this, STATUS, s, s | SIGNAL)) {
synchronized (this) {
throw new CancellationException();
if (s != EXCEPTIONAL)
throw new TimeoutException();
if ((ex = getThrowableException()) != null)
throw new ExecutionException(ex);
代码示例来源:origin: org.eclipse.jetty/jetty-util
@Override
public C get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
{
if (!_latch.await(timeout,unit))
throw new TimeoutException();
if (_cause==COMPLETED)
return _result;
if (_cause instanceof TimeoutException)
throw (TimeoutException)_cause;
if (_cause instanceof CancellationException)
throw (CancellationException) new CancellationException().initCause(_cause);
throw new ExecutionException(_cause);
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
private synchronized T doGet(Long timeoutMs)
throws InterruptedException, ExecutionException, TimeoutException {
if (mException != null) {
throw new ExecutionException(mException);
}
if (mResultReceived) {
return mResult;
}
if (timeoutMs == null) {
wait(0);
} else if (timeoutMs > 0) {
wait(timeoutMs);
}
if (mException != null) {
throw new ExecutionException(mException);
}
if (!mResultReceived) {
throw new TimeoutException();
}
return mResult;
}
代码示例来源:origin: apache/avro
/**
* Waits for the CallFuture to complete without returning the result.
* @param timeout the maximum time to wait.
* @param unit the time unit of the timeout argument.
* @throws InterruptedException if interrupted.
* @throws TimeoutException if the wait timed out.
*/
public void await(long timeout, TimeUnit unit)
throws InterruptedException, TimeoutException {
if (!latch.await(timeout, unit)) {
throw new TimeoutException();
}
}
代码示例来源:origin: vipshop/vjtools
@Override
public synchronized T get(final long timeout, final TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
Validate.notNull(unit, "Time unit");
final long msecs = unit.toMillis(timeout);
final long startTime = (msecs <= 0) ? 0 : System.currentTimeMillis();
long waitTime = msecs;
if (this.completed) {
return getResult();
} else if (waitTime <= 0) {
throw new TimeoutException();
} else {
for (;;) {
wait(waitTime);
if (this.completed) {
return getResult();
} else {
waitTime = msecs - (System.currentTimeMillis() - startTime);
if (waitTime <= 0) {
throw new TimeoutException();
}
}
}
}
}
代码示例来源:origin: robovm/robovm
if ((ms = TimeUnit.NANOSECONDS.toMillis(ns)) > 0L &&
U.compareAndSwapInt(this, STATUS, s, s | SIGNAL)) {
synchronized (this) {
throw new CancellationException();
if (s != EXCEPTIONAL)
throw new TimeoutException();
if ((ex = getThrowableException()) != null)
throw new ExecutionException(ex);
内容来源于网络,如有侵权,请联系作者删除!