com.google.common.util.concurrent.AbstractFuture.isCancelled()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中com.google.common.util.concurrent.AbstractFuture.isCancelled()方法的一些代码示例,展示了AbstractFuture.isCancelled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractFuture.isCancelled()方法的具体详情如下:
包路径:com.google.common.util.concurrent.AbstractFuture
类名称:AbstractFuture
方法名:isCancelled

AbstractFuture.isCancelled介绍

暂无

代码示例

代码示例来源:origin: google/guava

@Override
public final boolean isCancelled() {
 return super.isCancelled();
}

代码示例来源:origin: google/j2objc

@Override
public final boolean isCancelled() {
 return super.isCancelled();
}

代码示例来源:origin: wildfly/wildfly

@Override
public final boolean isCancelled() {
 return super.isCancelled();
}

代码示例来源:origin: google/guava

/**
 * If this future has been cancelled (and possibly interrupted), cancels (and possibly interrupts)
 * the given future (if available).
 */
final void maybePropagateCancellationTo(@Nullable Future<?> related) {
 if (related != null & isCancelled()) {
  related.cancel(wasInterrupted());
 }
}

代码示例来源:origin: google/guava

@Override
public String toString() {
 StringBuilder builder = new StringBuilder().append(super.toString()).append("[status=");
 if (isCancelled()) {
  builder.append("CANCELLED");
 } else if (isDone()) {
  addDoneString(builder);
 } else {
  String pendingDescription;
  try {
   pendingDescription = pendingToString();
  } catch (RuntimeException e) {
   // Don't call getMessage or toString() on the exception, in case the exception thrown by the
   // subclass is implemented with bugs similar to the subclass.
   pendingDescription = "Exception thrown from implementation: " + e.getClass();
  }
  // The future may complete during or before the call to getPendingToString, so we use null
  // as a signal that we should try checking if the future is done again.
  if (pendingDescription != null && !pendingDescription.isEmpty()) {
   builder.append("PENDING, info=[").append(pendingDescription).append("]");
  } else if (isDone()) {
   addDoneString(builder);
  } else {
   builder.append("PENDING");
  }
 }
 return builder.append("]").toString();
}

代码示例来源:origin: google/j2objc

/**
 * If this future has been cancelled (and possibly interrupted), cancels (and possibly interrupts)
 * the given future (if available).
 */
final void maybePropagateCancellationTo(@NullableDecl Future<?> related) {
 if (related != null & isCancelled()) {
  related.cancel(wasInterrupted());
 }
}

代码示例来源:origin: wildfly/wildfly

/**
 * If this future has been cancelled (and possibly interrupted), cancels (and possibly interrupts)
 * the given future (if available).
 */
final void maybePropagateCancellationTo(@NullableDecl Future<?> related) {
 if (related != null & isCancelled()) {
  related.cancel(wasInterrupted());
 }
}

代码示例来源:origin: google/j2objc

@Override
public String toString() {
 StringBuilder builder = new StringBuilder().append(super.toString()).append("[status=");
 if (isCancelled()) {
  builder.append("CANCELLED");
 } else if (isDone()) {
  addDoneString(builder);
 } else {
  String pendingDescription;
  try {
   pendingDescription = pendingToString();
  } catch (RuntimeException e) {
   // Don't call getMessage or toString() on the exception, in case the exception thrown by the
   // subclass is implemented with bugs similar to the subclass.
   pendingDescription = "Exception thrown from implementation: " + e.getClass();
  }
  // The future may complete during or before the call to getPendingToString, so we use null
  // as a signal that we should try checking if the future is done again.
  if (!isNullOrEmpty(pendingDescription)) {
   builder.append("PENDING, info=[").append(pendingDescription).append("]");
  } else if (isDone()) {
   addDoneString(builder);
  } else {
   builder.append("PENDING");
  }
 }
 return builder.append("]").toString();
}

代码示例来源:origin: wildfly/wildfly

@Override
public String toString() {
 StringBuilder builder = new StringBuilder().append(super.toString()).append("[status=");
 if (isCancelled()) {
  builder.append("CANCELLED");
 } else if (isDone()) {
  addDoneString(builder);
 } else {
  String pendingDescription;
  try {
   pendingDescription = pendingToString();
  } catch (RuntimeException e) {
   // Don't call getMessage or toString() on the exception, in case the exception thrown by the
   // subclass is implemented with bugs similar to the subclass.
   pendingDescription = "Exception thrown from implementation: " + e.getClass();
  }
  // The future may complete during or before the call to getPendingToString, so we use null
  // as a signal that we should try checking if the future is done again.
  if (!isNullOrEmpty(pendingDescription)) {
   builder.append("PENDING, info=[").append(pendingDescription).append("]");
  } else if (isDone()) {
   addDoneString(builder);
  } else {
   builder.append("PENDING");
  }
 }
 return builder.append("]").toString();
}

代码示例来源:origin: google/guava

private static void assertSuccessful(AbstractFuture<Integer> future, Integer expectedResult)
  throws InterruptedException, TimeoutException, ExecutionException {
 assertDone(future);
 assertThat(future.isCancelled()).isFalse();
 assertThat(getDone(future)).isEqualTo(expectedResult);
 assertThat(getDoneFromTimeoutOverload(future)).isEqualTo(expectedResult);
}

代码示例来源:origin: google/guava

private static void assertPending(AbstractFuture<Integer> future) {
 assertThat(future.isDone()).isFalse();
 assertThat(future.isCancelled()).isFalse();
 CountingRunnable listener = new CountingRunnable();
 future.addListener(listener, directExecutor());
 listener.assertNotRun();
 verifyGetOnPendingFuture(future);
 verifyTimedGetOnPendingFuture(future);
}

代码示例来源:origin: google/guava

assertTrue(future.isCancelled());
assertTrue(cancellationSucess.get());
assertFalse(setFutureSuccess.get());

代码示例来源:origin: google/guava

private static void assertFailed(AbstractFuture<Integer> future, Throwable expectedException)
  throws InterruptedException, TimeoutException {
 assertDone(future);
 assertThat(future.isCancelled()).isFalse();
 try {
  getDone(future);
  fail();
 } catch (ExecutionException e) {
  assertThat(e.getCause()).isSameAs(expectedException);
 }
 try {
  getDoneFromTimeoutOverload(future);
  fail();
 } catch (ExecutionException e) {
  assertThat(e).hasCauseThat().isSameAs(expectedException);
 }
}

代码示例来源:origin: google/guava

assertTrue(future.isCancelled());
assertTrue(cancellationSucess.get());
 assertTrue(setFuture.isCancelled());

代码示例来源:origin: google/guava

private static void assertCancelled(AbstractFuture<Integer> future, boolean expectWasInterrupted)
  throws InterruptedException, TimeoutException, ExecutionException {
 assertDone(future);
 assertThat(future.isCancelled()).isTrue();
 assertThat(future.wasInterrupted()).isEqualTo(expectWasInterrupted);
 try {
  getDone(future);
  fail();
 } catch (CancellationException expected) {
 }
 try {
  getDoneFromTimeoutOverload(future);
  fail();
 } catch (CancellationException expected) {
 }
}

代码示例来源:origin: google/guava

assertTrue(future.isCancelled());
if (future.wasInterrupted()) {

代码示例来源:origin: google/guava

public void testCancel_done() throws Exception {
 AbstractFuture<String> future =
   new AbstractFuture<String>() {
    {
     set("foo");
    }
   };
 assertFalse(future.cancel(true));
 assertFalse(future.isCancelled());
 assertTrue(future.isDone());
}

代码示例来源:origin: jclouds/legacy-jclouds

public boolean apply(String in) {
   if (futureWhichMightBeCancelled.isCancelled())
     throw new CancellationException(futureWhichMightBeCancelled + " is cancelled");
   return true;
  }
}), period, maxPeriod, MILLISECONDS);

代码示例来源:origin: org.apache.jclouds/jclouds-compute

public boolean apply(String in) {
   if (futureWhichMightBeCancelled.isCancelled())
     throw new CancellationException(futureWhichMightBeCancelled + " is cancelled");
   return true;
  }
}), period, maxPeriod, MILLISECONDS);

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * If this future has been cancelled (and possibly interrupted), cancels (and possibly interrupts)
 * the given future (if available).
 */
final void maybePropagateCancellationTo(@Nullable Future<?> related) {
 if (related != null & isCancelled()) {
  related.cancel(wasInterrupted());
 }
}

相关文章