當前位置: 首頁>>代碼示例>>Java>>正文


Java ListenableFuture.cancel方法代碼示例

本文整理匯總了Java中com.google.common.util.concurrent.ListenableFuture.cancel方法的典型用法代碼示例。如果您正苦於以下問題:Java ListenableFuture.cancel方法的具體用法?Java ListenableFuture.cancel怎麽用?Java ListenableFuture.cancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.util.concurrent.ListenableFuture的用法示例。


在下文中一共展示了ListenableFuture.cancel方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: waitForAllPartUploads

import com.google.common.util.concurrent.ListenableFuture; //導入方法依賴的package包/類
public List<PartETag> waitForAllPartUploads() throws IOException {
  try {
    return Futures.allAsList(partETagsFutures).get();
  } catch (InterruptedException ie) {
    LOG.warn("Interrupted partUpload:" + ie, ie);
    Thread.currentThread().interrupt();
  } catch (ExecutionException ee) {
    //there is no way of recovering so abort
    //cancel all partUploads
    for (ListenableFuture<PartETag> future : partETagsFutures) {
      future.cancel(true);
    }
    //abort multipartupload
    this.abort();
    throw new IOException("Part upload failed in multi-part upload with " +
        "id '" +uploadId + "':" + ee, ee);
  }
  //should not happen?
  return null;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:S3AFastOutputStream.java

示例2: cancelOthers

import com.google.common.util.concurrent.ListenableFuture; //導入方法依賴的package包/類
private void cancelOthers(ListenableFuture besidesThis) {
    for (ListenableFuture future : futures) {
        if (future != besidesThis) {
            try {
                future.cancel(true);
            } catch (Exception e) {
            }
        }
    }
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:11,代碼來源:AnyFuture.java

示例3: cancelCurrentBlock

import com.google.common.util.concurrent.ListenableFuture; //導入方法依賴的package包/類
protected synchronized void cancelCurrentBlock() {
    for (ListenableFuture<MiningResult> task : currentMiningTasks) {
        if (task != null && !task.isCancelled()) {
            task.cancel(true);
        }
    }
    currentMiningTasks.clear();

    if (miningBlock != null) {
        fireBlockCancelled(miningBlock);
        logger.debug("Tainted block mining cancelled: {}", miningBlock.getShortDescr());
        miningBlock = null;
    }
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:15,代碼來源:BlockMiner.java

示例4: backwardsCancelShouldWork

import com.google.common.util.concurrent.ListenableFuture; //導入方法依賴的package包/類
@Test
public void backwardsCancelShouldWork() {
    CompletableFuture<String> cf = new CompletableFuture<>();
    ListenableFuture<String> lf = MoreFutures.fromCompletableFuture(cf);

    lf.cancel(true);

    assertThat(cf.isDone()).isTrue();
    assertThat(cf.isCancelled()).isTrue();
}
 
開發者ID:salesforce,項目名稱:grpc-java-contrib,代碼行數:11,代碼來源:FromCompletableFutureTest.java

示例5: interruptJob

import com.google.common.util.concurrent.ListenableFuture; //導入方法依賴的package包/類
/**
 * Interrupt the job and make it ACTIVE
 * @param yadaJob
 */
public void interruptJob(Long yadaJobId) {
	log.debug("Interrupting job id {}", yadaJobId);
	ListenableFuture<?> jobHandle = jobHandles.get(yadaJobId);
	if (jobHandle!=null) {
		jobHandle.cancel(true);
	} else {
		log.debug("No job handle found for job id {} when interrupting", yadaJobId);
	}
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:14,代碼來源:YadaJobScheduler.java


注:本文中的com.google.common.util.concurrent.ListenableFuture.cancel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。