예제 #1
0
Future<HashValue> ContentHashCache::computeHash(
    const ContentHashCacheKey& key) const {
  return makeFuture(key)
      .via(&getThreadPool())
      .then([this](Result<ContentHashCacheKey>&& key) {
        return computeHashImmediate(key.value());
      });
}
예제 #2
0
void ZMultiTaskManager::start()
{
  if (m_taskArray.empty()) {
    return;
  }

#ifdef _DEBUG_
  std::cout << "Start with " << getThreadPool()->maxThreadCount() << " threads."
            << std::endl;
#endif
  startProgress();
  prepare();

  foreach (ZTask *task, m_taskArray) {
#ifdef _DEBUG_2
    std::cout << "Start task" << std::endl;
#endif
    getThreadPool()->start(task);
  }
예제 #3
0
ZMultiTaskManager::ZMultiTaskManager(QObject *parent) :
  QObject(parent), m_activeTaskNumber(0)
{
  getThreadPool()->setExpiryTimeout(-1);
  getThreadPool()->setMaxThreadCount(QThread::idealThreadCount() - 1);
}
예제 #4
0
void ZMultiTaskManager::waitForDone()
{
  getThreadPool()->waitForDone();
}
예제 #5
0
        return MATCH_EXPR;                                                        \
    }                                                                             \
    void TPT_##TEST_NAME::_doTest()

COMMON_THREAD_POOL_TEST(UnusedPool) {
    getThreadPool();
}

COMMON_THREAD_POOL_TEST(CannotScheduleAfterShutdown) {
    auto& pool = getThreadPool();
    pool.shutdown();
    ASSERT_EQ(ErrorCodes::ShutdownInProgress, pool.schedule([] {}));
}

COMMON_THREAD_POOL_DEATH_TEST(DieOnDoubleStartUp, "it has already started") {
    auto& pool = getThreadPool();
    pool.startup();
    pool.startup();
}

COMMON_THREAD_POOL_DEATH_TEST(DieWhenExceptionBubblesUp, "Exception escaped task in") {
    auto& pool = getThreadPool();
    pool.startup();
    ASSERT_OK(pool.schedule([] {
        uassertStatusOK(Status({ErrorCodes::BadValue, "No good very bad exception"}));
    }));
    pool.shutdown();
    pool.join();
}

COMMON_THREAD_POOL_DEATH_TEST(DieOnDoubleJoin, "Attempted to join pool") {