本文整理了Java中java.util.concurrent.Future.isCancelled()
方法的一些代码示例,展示了Future.isCancelled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.isCancelled()
方法的具体详情如下:
包路径:java.util.concurrent.Future
类名称:Future
方法名:isCancelled
[英]Returns true if this task was cancelled before it completed normally.
[中]
代码示例来源:origin: jenkinsci/jenkins
private void push() {
if (DELAY_SECONDS < 0) return;
synchronized (lock) {
// Can be done or canceled in case of a bug or external intervention - do not allow it to hang there forever
if (nextSave != null && !(nextSave.isDone() || nextSave.isCancelled())) return;
nextSave = Timer.get().schedule(this, DELAY_SECONDS, TimeUnit.SECONDS);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public void stop() {
for (Future<?> future: this.expirationFutures.values()) {
future.cancel(true);
}
for (Future<?> future: this.expirationFutures.values()) {
if (!future.isCancelled() && !future.isDone()) {
try {
future.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
// Ignore
}
}
}
for(Map.Entry<K, Entry<V>> entry : entries.entrySet()) {
this.factory.destroyInstance(entry.getValue().getValue());
}
this.expirationFutures.clear();
this.entries.clear();
}
代码示例来源:origin: SonarSource/sonarqube
public void runFutures() throws ExecutionException, InterruptedException {
while (futures.peek() != null) {
Future<?> future = futures.poll();
if (!future.isCancelled()) {
future.get();
}
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public void run() {
boolean failures = false;
INSTALLING: while (true) {
try {
updateCenter.persistInstallStatus();
Thread.sleep(500);
failures = false;
for (Future<UpdateCenter.UpdateCenterJob> jobFuture : installJobs) {
if(!jobFuture.isDone() && !jobFuture.isCancelled()) {
continue INSTALLING;
}
UpdateCenter.UpdateCenterJob job = jobFuture.get();
if(job instanceof InstallationJob && ((InstallationJob)job).status instanceof DownloadJob.Failure) {
failures = true;
}
}
} catch (Exception e) {
LOGGER.log(WARNING, "Unexpected error while waiting for initial plugin set to install.", e);
}
break;
}
updateCenter.persistInstallStatus();
if(!failures) {
try (ACLContext acl = ACL.as(currentAuth)) {
InstallUtil.proceedToNextStateFrom(InstallState.INITIAL_PLUGINS_INSTALLING);
}
}
}
}.start();
代码示例来源:origin: apache/incubator-gobblin
public static <R> CallbackResult<R> createFromFuture(Future<R> execFuture)
throws InterruptedException {
Preconditions.checkNotNull(execFuture);
if (execFuture.isCancelled()) {
return createCancelled();
}
try {
R res = execFuture.get();
return createSuccessful(res);
}
catch (ExecutionException e) {
if (execFuture.isCancelled()) {
return createCancelled();
}
else {
return createFailed(e.getCause());
}
}
}
}
代码示例来源:origin: alibaba/yugong
public void cacelAllFutures() {
for (Future future : futures) {
if (!future.isDone() && !future.isCancelled()) {
future.cancel(true);
}
}
}
代码示例来源:origin: stackoverflow.com
return src.isCancelled();
return src.isDone();
return src.get();
return src.get();
代码示例来源:origin: apache/activemq
if (futureOrLong instanceof Future) {
Future future = (Future) futureOrLong;
if (future.isCancelled()) {
continue;
future.get(5, TimeUnit.SECONDS);
setLastCachedId(ASYNC_ADD, lastPending);
} catch (CancellationException ok) {
代码示例来源:origin: apache/geode
private void clearCompletedFutures() {
futures.removeIf(future -> future.isCancelled() || future.isDone());
}
代码示例来源:origin: apache/activemq
if (futureOrLong instanceof Future) {
Future future = (Future) futureOrLong;
if (future.isDone()) {
if (future.isCancelled()) {
it.remove();
} else {
future.get(0, TimeUnit.SECONDS);
代码示例来源:origin: voldemort/voldemort
if(f.isCancelled()) {
logger.warn("Get operation timed out after " + timeoutMs + " ms.");
continue;
GetAllResult getResult = f.get();
if(getResult.exception != null) {
if(getResult.exception instanceof VoldemortApplicationException) {
代码示例来源:origin: jenkinsci/jenkins
@Override
public void run() {
INSTALLING: while (true) {
for (Future<UpdateCenter.UpdateCenterJob> deployJob : installJobs) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
LOGGER.log(SEVERE, "Unexpected error while waiting for some plugins to install. Plugin Manager state may be invalid. Please restart Jenkins ASAP.", e);
}
if (!deployJob.isCancelled() && !deployJob.isDone()) {
// One of the plugins is not installing/canceled, so
// go back to sleep and try again in a while.
continue INSTALLING;
}
}
// All the plugins are installed. It's now safe to refresh.
resolveDependantPlugins();
break;
}
}
}.start();
代码示例来源:origin: spring-projects/spring-data-redis
for (Map.Entry<NodeExecution, Future<NodeResult<T>>> entry : futures.entrySet()) {
if (!entry.getValue().isDone() && !entry.getValue().isCancelled()) {
done = false;
} else {
result.add(execution.getPositionalKey(), entry.getValue().get());
} else {
result.add(entry.getValue().get());
代码示例来源:origin: voldemort/voldemort
if(f.isCancelled()) {
logger.warn("Get operation timed out after " + timeoutMs + " ms.");
continue;
GetResult<R> getResult = f.get();
if(getResult.exception != null) {
if(getResult.exception instanceof VoldemortApplicationException) {
代码示例来源:origin: wildfly/wildfly
@ManagedAttribute
public boolean getStableTaskRunning() {
stable_task_lock.lock();
try {
return stable_task_future != null && !stable_task_future.isDone() && !stable_task_future.isCancelled();
}
finally {
stable_task_lock.unlock();
}
}
代码示例来源:origin: apache/geode
DistributedMember returnedMember = futureTask.get();
String memberId = returnedMember != null ? returnedMember.getId() : null;
if (futureTask.isDone()) {
if (isDebugEnabled) {
logger.debug("Monitoring Resource Created for : {}", memberId);
if (futureTask.isCancelled()) {
代码示例来源:origin: SonarSource/sonarqube
while (processingExecutorService.futures.peek() != null) {
Future<?> future = processingExecutorService.futures.poll();
if (future.isCancelled()) {
cancelledTaskFutureCount++;
} else {
future.get();
代码示例来源:origin: wildfly/wildfly
@ManagedAttribute
public boolean isOpenerScheduled() {
return barrier_opener_future != null && !barrier_opener_future.isDone() && !barrier_opener_future.isCancelled();
}
代码示例来源:origin: ReactiveX/RxJava
final Future<?> f = Single.never().toFuture();
assertFalse(f.isCancelled());
assertFalse(f.isDone());
assertTrue(f.isCancelled());
assertTrue(f.isDone());
f.get();
fail("Should have thrown!");
} catch (CancellationException ex) {
f.get(5, TimeUnit.SECONDS);
fail("Should have thrown!");
} catch (CancellationException ex) {
代码示例来源:origin: apache/activemq
for (Future<Object> result : results) {
try {
result.get();
} catch (InterruptedException e) {
theStore.brokerService.handleIOException(new IOException(e.getMessage()));
}catch(CancellationException e) {
if (!result.isCancelled()) {
doneSomething = true;
内容来源于网络,如有侵权,请联系作者删除!