本文整理了Java中java.util.concurrent.FutureTask.isCancelled()
方法的一些代码示例,展示了FutureTask.isCancelled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FutureTask.isCancelled()
方法的具体详情如下:
包路径:java.util.concurrent.FutureTask
类名称:FutureTask
方法名:isCancelled
暂无
代码示例来源:origin: PipelineAI/pipeline
@Override
public boolean isUnsubscribed() {
return f.isCancelled();
}
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
public final boolean isCancelled() {
return mFuture.isCancelled();
}
代码示例来源:origin: robolectric/robolectric
@Implementation
protected boolean isCancelled() {
return future.isCancelled();
}
代码示例来源:origin: ehcache/ehcache3
public static void shutdownNow(ExecutorService executor) {
for (Runnable r : executor.shutdownNow()) {
if (!(r instanceof FutureTask) || !((FutureTask<?>) r).isCancelled()) {
try {
r.run();
} catch (Throwable t) {
LOGGER.warn("Exception executing task left in {}: {}", executor, t);
}
}
}
terminate(executor);
}
代码示例来源:origin: twosigma/beakerx
private TryResult getResult(FutureTask<TryResult> ret) {
TryResult o;
try {
o = ret.get();
} catch (Exception e) {
e.printStackTrace();
return TryResult.createError(e.getMessage());
}
if (ret.isCancelled())
return TryResult.createError("Cancelled");
return o;
}
代码示例来源:origin: airbnb/lottie-android
@Override public void run() {
if (result == null || task.isCancelled()) {
return;
}
// Local reference in case it gets set on a background thread.
LottieResult<T> result = LottieTask.this.result;
if (result.getValue() != null) {
notifySuccessListeners(result.getValue());
} else {
notifyFailureListeners(result.getException());
}
}
});
代码示例来源:origin: apache/nifi
try {
if (task.isDone()) {
if (task.isCancelled()) {
if (logger.isDebugEnabled()) {
logger.debug("A flow controller execution task '{}' has been cancelled.", runnable);
代码示例来源:origin: ReactiveX/RxJava
@Test
public void disposeOnCurrentThread() throws Exception {
ExecutorService exec = Executors.newSingleThreadExecutor();
try {
InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() {
@Override
public void run() {
throw new TestException();
}
}, exec);
task.runner = Thread.currentThread();
task.dispose();
FutureTask<Void> f1 = new FutureTask<Void>(Functions.EMPTY_RUNNABLE, null);
task.setFirst(f1);
assertTrue(f1.isCancelled());
FutureTask<Void> f2 = new FutureTask<Void>(Functions.EMPTY_RUNNABLE, null);
task.setRest(f2);
assertTrue(f2.isCancelled());
} finally {
exec.shutdownNow();
RxJavaPlugins.reset();
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void dispose3() throws Exception {
ExecutorService exec = Executors.newSingleThreadExecutor();
try {
InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() {
@Override
public void run() {
throw new TestException();
}
}, exec);
task.dispose();
FutureTask<Void> f1 = new FutureTask<Void>(Functions.EMPTY_RUNNABLE, null);
task.setFirst(f1);
assertTrue(f1.isCancelled());
FutureTask<Void> f2 = new FutureTask<Void>(Functions.EMPTY_RUNNABLE, null);
task.setRest(f2);
assertTrue(f2.isCancelled());
} finally {
exec.shutdownNow();
RxJavaPlugins.reset();
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void normal() {
FutureTask<Object> ft = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
Disposable d = Disposables.fromFuture(ft);
assertFalse(d.isDisposed());
d.dispose();
assertTrue(d.isDisposed());
d.dispose();
assertTrue(d.isDisposed());
assertTrue(ft.isCancelled());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void interruptible() {
FutureTask<Object> ft = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
Disposable d = Disposables.fromFuture(ft, true);
assertFalse(d.isDisposed());
d.dispose();
assertTrue(d.isDisposed());
d.dispose();
assertTrue(d.isDisposed());
assertTrue(ft.isCancelled());
}
代码示例来源:origin: MovingBlocks/Terasology
@Override
public void update(float delta) {
super.update(delta);
if (parallelTask == null) {
return; // idle
}
if (!parallelTask.isDone()) {
return; // still running
}
if (parallelTask.isCancelled()) {
// wait for the thread to die
if (!thread.isAlive()) {
getManager().popScreen();
}
return;
}
try {
T result = parallelTask.get();
getManager().popScreen();
if (resultEvent != null) {
resultEvent.accept(result);
}
} catch (InterruptedException | ExecutionException e) {
logger.warn("An error occurred during execution", e);
getManager().popScreen();
getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error", e.getMessage());
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void disposeOnCurrentThread() {
ExecutorService exec = Executors.newSingleThreadExecutor();
Disposable.Composite composit = Disposables.composite();
try {
InstantPeriodicWorkerTask task = new InstantPeriodicWorkerTask(errorRunnable, exec, composit);
task.thread = Thread.currentThread();
task.dispose();
FutureTask<Void> f1 = new FutureTask<Void>(emptyRunnable, null);
task.setFirst(f1);
assertThat(f1.isCancelled()).isTrue();
FutureTask<Void> f2 = new FutureTask<Void>(emptyRunnable, null);
task.setRest(f2);
assertThat(f2.isCancelled()).isTrue();
}
finally {
exec.shutdownNow();
Schedulers.resetOnHandleError();
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void dispose3() {
ExecutorService exec = Executors.newSingleThreadExecutor();
Disposable.Composite composit = Disposables.composite();
try {
InstantPeriodicWorkerTask task = new InstantPeriodicWorkerTask(errorRunnable, exec, composit);
task.dispose();
FutureTask<Void> f1 = new FutureTask<Void>(emptyRunnable, null);
task.setFirst(f1);
assertThat(f1.isCancelled()).isTrue();
FutureTask<Void> f2 = new FutureTask<Void>(emptyRunnable, null);
task.setRest(f2);
assertThat(f2.isCancelled()).isTrue();
}
finally {
exec.shutdownNow();
Schedulers.resetOnHandleError();
}
}
代码示例来源:origin: ReactiveX/RxJava
assertTrue(f1.isCancelled());
assertTrue(task.isDisposed());
代码示例来源:origin: ReactiveX/RxJava
assertTrue(f1.isCancelled());
assertTrue(task.isDisposed());
代码示例来源:origin: stackoverflow.com
return mFuture.isCancelled();
代码示例来源:origin: ebean-orm/ebean
@Override
public boolean isCancelled() {
return futureTask.isCancelled();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void restCancelRace() {
ExecutorService exec = Executors.newSingleThreadExecutor();
Disposable.Composite composit = Disposables.composite();
try {
for (int i = 0; i < 10000; i++) {
final InstantPeriodicWorkerTask task = new InstantPeriodicWorkerTask(errorRunnable, exec, composit);
final FutureTask<Void> f1 = new FutureTask<Void>(emptyRunnable, null);
Runnable r1 = () -> task.setRest(f1);
Runnable r2 = task::dispose;
RaceTestUtils.race(r1, r2);
assertTrue(f1.isCancelled());
assertTrue(task.isDisposed());
}
}
finally {
exec.shutdownNow();
Schedulers.resetOnHandleError();
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void firstCancelRace() {
ExecutorService exec = Executors.newSingleThreadExecutor();
Disposable.Composite composit = Disposables.composite();
try {
for (int i = 0; i < 10000; i++) {
final InstantPeriodicWorkerTask task = new InstantPeriodicWorkerTask(errorRunnable, exec, composit);
final FutureTask<Void>
f1 = new FutureTask<Void>(emptyRunnable, null);
Runnable r1 = () -> task.setFirst(f1);
Runnable r2 = task::dispose;
RaceTestUtils.race(r1, r2);
assertTrue(f1.isCancelled());
assertTrue(task.isDisposed());
}
}
finally {
exec.shutdownNow();
Schedulers.resetOnHandleError();
}
}
内容来源于网络,如有侵权,请联系作者删除!