当前位置: 首页>>代码示例>>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;未经允许,请勿转载。