本文整理了Java中java.util.concurrent.ScheduledFuture.getDelay()
方法的一些代码示例,展示了ScheduledFuture.getDelay()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScheduledFuture.getDelay()
方法的具体详情如下:
包路径:java.util.concurrent.ScheduledFuture
类名称:ScheduledFuture
方法名:getDelay
暂无
代码示例来源:origin: google/guava
@Override
public long getDelay(TimeUnit unit) {
return scheduledDelegate.getDelay(unit);
}
代码示例来源:origin: google/guava
@Override
protected String pendingToString() {
ListenableFuture<? extends V> localInputFuture = delegateRef;
ScheduledFuture<?> localTimer = timer;
if (localInputFuture != null) {
String message = "inputFuture=[" + localInputFuture + "]";
if (localTimer != null) {
final long delay = localTimer.getDelay(TimeUnit.MILLISECONDS);
// Negative delays look confusing in an error message
if (delay > 0) {
message += ", remaining delay=[" + delay + " ms]";
}
}
return message;
}
return null;
}
代码示例来源:origin: prestodb/presto
@Override
public long getDelay(TimeUnit unit) {
return scheduledDelegate.getDelay(unit);
}
代码示例来源:origin: google/j2objc
@Override
public long getDelay(TimeUnit unit) {
return scheduledDelegate.getDelay(unit);
}
代码示例来源:origin: wildfly/wildfly
@Override
public long getDelay(TimeUnit unit) {
return scheduledDelegate.getDelay(unit);
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public long getDelay(TimeUnit unit) {
return scheduledDelegate.getDelay(unit);
}
代码示例来源:origin: apache/geode
@Override
public long getDelay(TimeUnit unit) {
return delegate.getDelay(unit);
}
代码示例来源:origin: apache/geode
public long getRemainingDelay() {
return future.getDelay(TimeUnit.MILLISECONDS);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public long getDelay(TimeUnit unit) {
ScheduledFuture<?> curr;
synchronized (this.triggerContextMonitor) {
curr = obtainCurrentFuture();
}
return curr.getDelay(unit);
}
代码示例来源:origin: apache/geode
/**
* Get remaining expiration time
*
* @param key Key
* @return Remaining time in milliseconds or 0 if no delay or key doesn't exist
*/
public long getExpirationDelayMillis(ByteArrayWrapper key) {
ScheduledFuture<?> future = this.expirationsMap.get(key);
return future != null ? future.getDelay(TimeUnit.MILLISECONDS) : 0L;
}
代码示例来源:origin: org.springframework/spring-context
@Override
public long getDelay(TimeUnit unit) {
ScheduledFuture<?> curr;
synchronized (this.triggerContextMonitor) {
curr = obtainCurrentFuture();
}
return curr.getDelay(unit);
}
代码示例来源:origin: google/guava
/**
* Provide a human-readable explanation of why this future has not yet completed.
*
* @return null if an explanation cannot be provided because the future is done.
* @since 23.0
*/
protected @Nullable String pendingToString() {
Object localValue = value;
if (localValue instanceof SetFuture) {
return "setFuture=[" + userObjectToString(((SetFuture) localValue).future) + "]";
} else if (this instanceof ScheduledFuture) {
return "remaining delay=["
+ ((ScheduledFuture) this).getDelay(TimeUnit.MILLISECONDS)
+ " ms]";
}
return null;
}
代码示例来源:origin: prestodb/presto
/**
* Provide a human-readable explanation of why this future has not yet completed.
*
* @return null if an explanation cannot be provided because the future is done.
* @since 23.0
*/
@NullableDecl
protected String pendingToString() {
Object localValue = value;
if (localValue instanceof SetFuture) {
return "setFuture=[" + userObjectToString(((SetFuture) localValue).future) + "]";
} else if (this instanceof ScheduledFuture) {
return "remaining delay=["
+ ((ScheduledFuture) this).getDelay(TimeUnit.MILLISECONDS)
+ " ms]";
}
return null;
}
代码示例来源:origin: apache/hbase
/**
* For JMX to forget about all previously exported metrics.
*/
public static void clearJmxCache() {
if (LOG.isTraceEnabled()) {
LOG.trace("clearing JMX Cache" + StringUtils.stringifyException(new Exception()));
}
//If there are more then 100 ms before the executor will run then everything should be merged.
ScheduledFuture future = fut.get();
if ((future != null && (!future.isDone() && future.getDelay(TimeUnit.MILLISECONDS) > 100))) {
// BAIL OUT
return;
}
if (stopped.get()) {
return;
}
future = executor.getExecutor().schedule(new JmxCacheBusterRunnable(), 5, TimeUnit.SECONDS);
fut.set(future);
}
代码示例来源:origin: google/j2objc
/**
* Provide a human-readable explanation of why this future has not yet completed.
*
* @return null if an explanation cannot be provided because the future is done.
* @since 23.0
*/
@NullableDecl
protected String pendingToString() {
Object localValue = value;
if (localValue instanceof SetFuture) {
return "setFuture=[" + userObjectToString(((SetFuture) localValue).future) + "]";
} else if (this instanceof ScheduledFuture) {
return "remaining delay=["
+ ((ScheduledFuture) this).getDelay(TimeUnit.MILLISECONDS)
+ " ms]";
}
return null;
}
代码示例来源:origin: wildfly/wildfly
/**
* Provide a human-readable explanation of why this future has not yet completed.
*
* @return null if an explanation cannot be provided because the future is done.
* @since 23.0
*/
@NullableDecl
protected String pendingToString() {
Object localValue = value;
if (localValue instanceof SetFuture) {
return "setFuture=[" + userObjectToString(((SetFuture) localValue).future) + "]";
} else if (this instanceof ScheduledFuture) {
return "remaining delay=["
+ ((ScheduledFuture) this).getDelay(TimeUnit.MILLISECONDS)
+ " ms]";
}
return null;
}
代码示例来源:origin: apache/geode
/**
* Schedule an execution of a task. This will either add the task to the execution service, or if
* a task has already been scheduled through this decorator and is still pending execution it will
* return the future associated with the previously scheduled task.
*
* @param runnable a runnable to execution
* @param delay the time to delay before execution
* @param unit the time unit
* @return The future associated with this task, or with a previously scheduled task if that task
* has not yet been run.
* @see ScheduledExecutorService#schedule(Runnable, long, TimeUnit)
*/
public ScheduledFuture<?> schedule(Runnable runnable, long delay, TimeUnit unit) {
synchronized (this) {
if (future == null || future.isCancelled() || future.isDone()
|| future.getDelay(unit) > delay) {
if (future != null && !future.isDone()) {
future.cancel(false);
listener.taskDropped();
}
future = ex.schedule(new DelegatingRunnable(runnable), delay, unit);
} else {
listener.taskDropped();
}
}
return future;
}
代码示例来源:origin: apache/geode
/**
* Schedule an execution of a task. This will either add the task to the execution service, or if
* a task has already been scheduled through this decorator and is still pending execution it will
* return the future associated with the previously scheduled task.
*
* @param callable a callable to execute
* @param delay the time to delay before execution
* @param unit the time unit
* @return The future associated with this task, or with a previously scheduled task if that task
* has not yet been run.
* @see ScheduledExecutorService#schedule(Runnable, long, TimeUnit)
*/
public <T> ScheduledFuture<?> schedule(Callable<T> callable, long delay, TimeUnit unit) {
synchronized (this) {
if (future == null || future.isCancelled() || future.isDone()
|| future.getDelay(unit) > delay) {
if (future != null && !future.isDone()) {
future.cancel(false);
listener.taskDropped();
}
future = ex.schedule(new DelegatingCallable<T>(callable), delay, unit);
} else {
listener.taskDropped();
}
}
return future;
}
代码示例来源:origin: google/guava
String message = "Timed out";
if (timer != null) {
long overDelayMs = Math.abs(timer.getDelay(TimeUnit.MILLISECONDS));
if (overDelayMs > 10) { // Not all timing drift is worth reporting
message += " (timeout delayed by " + overDelayMs + " ms after scheduled time)";
代码示例来源:origin: Netflix/EVCache
long delayms = 0;
if(scheduledFuture != null) {
delayms = scheduledFuture.getDelay(TimeUnit.MILLISECONDS);
内容来源于网络,如有侵权,请联系作者删除!