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


Java BlockingDeque.isEmpty方法代碼示例

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


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

示例1: GwtcJobMonitorImpl

import java.util.concurrent.BlockingDeque; //導入方法依賴的package包/類
public GwtcJobMonitorImpl(BlockingDeque<String> caller, BlockingDeque<String> compiler) {
    // We were instantiated directly, so assume we are running in a foreign classloader,
    // and that our parameters are a pair of LinkedBlockingDeque's that we can use to communicate with.
    readAsCaller = compiler::take;
    readAsCompiler = caller::take;
    writeAsCaller = caller::put;
    writeAsCompiler = compiler::put;
    hasCallerOutput = ()->!caller.isEmpty();
    hasCompilerOutput = ()->!compiler.isEmpty();
}
 
開發者ID:WeTheInternet,項目名稱:xapi,代碼行數:11,代碼來源:GwtcJobMonitorImpl.java

示例2: getAllConfidence

import java.util.concurrent.BlockingDeque; //導入方法依賴的package包/類
public void getAllConfidence(Set<String> pokemonSet, int size) throws IOException {
    final Map<String, Double> confidences = new HashMap<>();

    //I'm so lazy right now.
    Set<Set<String>> pokemonSets = new HashSet<>();
    for (String p1 : pokemonSet) {
        if (size == 1) {
            pokemonSets.add(Sets.newHashSet(p1));
        } else {
            for (String p2 : pokemonSet) {
                if (p1.equals(p2)) continue;
                if (size == 2) {
                    pokemonSets.add(Sets.newHashSet(p1, p2));
                } else {
                    for (String p3 : pokemonSet) {
                        if (p1.equals(p3) || p2.equals(p3)) continue;
                        pokemonSets.add(Sets.newHashSet(p1,p2,p3));
                    }
                }
            }
        }
    }

    final BlockingDeque<Set<String>> pokemon = new LinkedBlockingDeque<>(pokemonSets);

    Runnable task = new Runnable() {
        @Override
        public void run() {
            while (!pokemon.isEmpty()) {
                Set<String> pokemonBeingAnalyzed = pokemon.poll();
                Double confidence;
                try {
                    confidence = new PokemonWinAnalysis(pokemonBeingAnalyzed).getConfidence();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(setToString(pokemonBeingAnalyzed) + ", " + confidence);
            }
        }
    };

    new Thread(task).start();
    new Thread(task).start();
    new Thread(task).start();
}
 
開發者ID:jking31cs,項目名稱:pokemon-learning,代碼行數:46,代碼來源:PokemonPerformanceAnalysis.java

示例3: assertExpectedUpdatesWritten

import java.util.concurrent.BlockingDeque; //導入方法依賴的package包/類
private void assertExpectedUpdatesWritten() throws InterruptedException {
    final AtomicReference<String> failureText = new AtomicReference<String>();
    cougarOutput.addListener(new ExpectingOutput.ExpectingOutputListener() {
        @Override
        public void failure(String s) {
            failureText.set(s);
        }

        @Override
        public void complete() {
        }
    });

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Starting wait for expected updates");
    }

    cougarOutput.start();

    BlockingDeque queue = subject.getHeapsWaitingForUpdate();
    while (!queue.isEmpty()) {
        Thread.sleep(10);
    }
    // queue empty, now check the heap stats
    boolean allDone = false;
    while (!allDone) {
        allDone = true;
        for (PooledServerConnectedObjectManager.HeapState heapState : subject.getHeapStates().values()) {
            Lock lock = heapState.getUpdateLock();
            lock.lock();
            try {
                if (!heapState.getQueuedChanges().isEmpty()) {
                    allDone = false;
                    break;
                }
            }
            finally {
                lock.unlock();
            }
        }
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("CougarObjectOutput.writeObject():");
        for (Object o : new ArrayList<Object>(cougarOutput.getAllValues())) {
            LOGGER.debug(String.valueOf(o));
        }
    }

    if (failureText.get() != null) {
        fail(failureText.get());
    }

    // add in checks for the terminate subs
    assertEquals(cougarOutput.getExpectedSubTerminations(), cougarOutput.getSubTerminations());
}
 
開發者ID:betfair,項目名稱:cougar,代碼行數:57,代碼來源:PooledServerConnectedObjectManagerTest.java


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