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

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

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

AbstractFuture.isDone介绍

暂无

代码示例

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

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

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

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

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

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

代码示例来源: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: org.apache.hadoop/hadoop-common

@Override
 public boolean isDone() {
  callAsyncGet(0, TimeUnit.MILLISECONDS);
  return super.isDone();
 }
}

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

@Override
 public void run() {
  future.set("success");
  if (!future.isDone()) {
   errorMessage.set("Set call exited before future was complete.");
  }
 }
});

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

@Override
 public void run() {
  future.setException(new IllegalArgumentException("failure"));
  if (!future.isDone()) {
   errorMessage.set("SetException call exited before future was complete.");
  }
 }
});

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

@Override
 public void run() {
  future.cancel(true);
  if (!future.isDone()) {
   errorMessage.set("Cancel call exited before future was complete.");
  }
 }
});

代码示例来源: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: google/guava

if (!isDone()) {
 Listener oldHead = listeners;
 if (oldHead != Listener.TOMBSTONE) {

代码示例来源: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

if (isDone()) {
 throw new TimeoutException(message + " but future completed as timeout expired");

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

public void testGetFailure_NotCompleted() {
 AbstractFuture<String> future = new AbstractFuture<String>() {};
 assertThat(future.isDone()).isFalse();
 assertThat(future.tryInternalFastPathGetFailure()).isNull();
}

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

private static void assertDone(AbstractFuture<Integer> future) {
 CountingRunnable listener = new CountingRunnable();
 future.addListener(listener, directExecutor());
 listener.assertRun();
 assertThat(future.isDone()).isTrue();
 assertCannotSet(future);
 assertCannotCancel(future);
}

代码示例来源: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

public void testEvilFuture_setFuture() throws Exception {
 final RuntimeException exception = new RuntimeException("you didn't say the magic word!");
 AbstractFuture<String> evilFuture =
   new AbstractFuture<String>() {
    @Override
    public void addListener(Runnable r, Executor e) {
     throw exception;
    }
   };
 AbstractFuture<String> normalFuture = new AbstractFuture<String>() {};
 normalFuture.setFuture(evilFuture);
 assertTrue(normalFuture.isDone());
 try {
  normalFuture.get();
  fail();
 } catch (ExecutionException e) {
  assertThat(e).hasCauseThat().isSameAs(exception);
 }
}

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

assertThat(future.isDone()).isTrue();

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

assertThat(future.isDone()).isTrue();

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

assertThat(future.isDone()).isTrue();

代码示例来源: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());
}

相关文章