当前位置: 首页>>代码示例>>C++>>正文


C++ pool函数代码示例

本文整理汇总了C++中pool函数的典型用法代码示例。如果您正苦于以下问题:C++ pool函数的具体用法?C++ pool怎么用?C++ pool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test

        void test( size_t nThreadCount )
        {
            ALLOC alloc;

            CPPUNIT_MSG( "Thread count=" << nThreadCount );
            CPPUNIT_MSG("Initialize data..." );

            randomGen<unsigned int> rndGen;

            s_nPassPerThread = s_nPassCount / nThreadCount;

            size_t nThread;
            m_aThreadData = new thread_data[ nThreadCount ];
            for ( nThread = 0; nThread < nThreadCount; ++nThread ) {
                thread_data thData
                    = m_aThreadData[nThread]
                    = new char *[ s_nBlocksPerThread ];
                    for ( size_t i = 0; i < s_nBlocksPerThread; ++i ) {
                        thData[i] = reinterpret_cast<char *>(alloc.allocate( rndGen( s_nMinBlockSize, s_nMaxBlockSize ), nullptr ));
                        CPPUNIT_ASSERT( (reinterpret_cast<uintptr_t>(thData[i]) & (ALLOC::alignment - 1)) == 0 );
                    }
            }
            CPPUNIT_MSG("Initializatin done" );

            CppUnitMini::ThreadPool pool( *this );
            pool.add( new Thread<ALLOC>( pool, alloc ), nThreadCount );
            nThread = 0;
            for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it )
                static_cast<Thread<ALLOC> *>(*it)->m_arr = m_aThreadData[nThread++];

            cds::OS::Timer    timer;
            pool.run();
            CPPUNIT_MSG( "  Duration=" << pool.avgDuration() );

            for ( nThread = 0; nThread < nThreadCount; ++nThread ) {
                thread_data thData = m_aThreadData[nThread];
                for ( size_t i = 0; i < s_nBlocksPerThread; ++i ) {
                    alloc.deallocate( reinterpret_cast<typename ALLOC::value_type *>(thData[i]), 1 );
                }
                delete [] thData;
            }
            delete [] m_aThreadData;
        }
开发者ID:3Hren,项目名称:libcds,代码行数:43,代码来源:larson.cpp

示例2: pool

void PushingToViewsBlockOutputStream::write(const Block & block)
{
    /** Throw an exception if the sizes of arrays - elements of nested data structures doesn't match.
      * We have to make this assertion before writing to table, because storage engine may assume that they have equal sizes.
      * NOTE It'd better to do this check in serialization of nested structures (in place when this assumption is required),
      * but currently we don't have methods for serialization of nested structures "as a whole".
      */
    Nested::validateArraySizes(block);

    if (output)
        output->write(block);

    /// Don't process materialized views if this block is duplicate
    if (replicated_output && replicated_output->lastBlockIsDuplicate())
        return;

    // Insert data into materialized views only after successful insert into main table
    const Settings & settings = context.getSettingsRef();
    if (settings.parallel_view_processing && views.size() > 1)
    {
        // Push to views concurrently if enabled, and more than one view is attached
        ThreadPool pool(std::min(size_t(settings.max_threads), views.size()));
        for (size_t view_num = 0; view_num < views.size(); ++view_num)
        {
            auto thread_group = CurrentThread::getGroup();
            pool.schedule([=]
            {
                setThreadName("PushingToViews");
                if (thread_group)
                    CurrentThread::attachToIfDetached(thread_group);
                process(block, view_num);
            });
        }
        // Wait for concurrent view processing
        pool.wait();
    }
    else
    {
        // Process sequentially
        for (size_t view_num = 0; view_num < views.size(); ++view_num)
            process(block, view_num);
    }
}
开发者ID:greck2908,项目名称:ClickHouse,代码行数:43,代码来源:PushingToViewsBlockOutputStream.cpp

示例3: pool

vector<string> RepositoryDependencyAnalyser::GetDependency(string modulePath)
{
	ThreadPool pool(5);
	auto metadata = RepositoryMetadataHelper::GetMetadata(modulePath);
	vector<string> fileList;
	vector<string> result;
	for (auto file : metadata.FileList) {
		fileList.push_back(RepositoryMetadataHelper::repository_path + "/" + metadata.getFullName() + "/" + file);
	}
	auto dependencies = test_getDependency(pool, fileList, &this->typeTable);
	for (size_t i = 0; i < dependencies.Size(); i++) {
		auto moduleIt = this->moduleLookupTable.find(dependencies[i].toFile);
		if (moduleIt != this->moduleLookupTable.end() && moduleIt->second != metadata.getFullName() 
			&& !RepositoryMetadata::VersionCompared(moduleIt->second, metadata.getFullName())) {
			result.push_back(moduleIt->second);
		}
	}
	return result;
}
开发者ID:cyfloel0516,项目名称:Remote_Code_Repository,代码行数:19,代码来源:RepositoryDependencyAnalyser.cpp

示例4: log

bool
DocCacheMemory::loadDoc(const TagKey *key, CacheContext *cache_ctx,
    Tag &tag, boost::shared_ptr<CacheData> &cache_data) {

    log()->debug("loading doc in memory cache");
    DocPool *mpool = pool(key);
    assert(NULL != mpool);

    DocCleaner cleaner(cache_ctx->context());
    if (!mpool->loadDoc(key->asString(), tag, cache_data, cleaner)) {
        return false;
    }

    if (!DocCacheBase::checkTag(NULL, NULL, tag, "loading doc from memory cache")) {
        return false;
    }
    
    return true;
}
开发者ID:bacek,项目名称:xscript,代码行数:19,代码来源:doc_cache_memory.cpp

示例5: host

void ElementShadow::distributeV0()
{
    host()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::Shadow));
    WillBeHeapVector<RawPtrWillBeMember<HTMLShadowElement>, 32> shadowInsertionPoints;
    DistributionPool pool(*host());

    for (ShadowRoot* root = &youngestShadowRoot(); root; root = root->olderShadowRoot()) {
        HTMLShadowElement* shadowInsertionPoint = 0;
        const WillBeHeapVector<RefPtrWillBeMember<InsertionPoint>>& insertionPoints = root->descendantInsertionPoints();
        for (size_t i = 0; i < insertionPoints.size(); ++i) {
            InsertionPoint* point = insertionPoints[i].get();
            if (!point->isActive())
                continue;
            if (isHTMLShadowElement(*point)) {
                ASSERT(!shadowInsertionPoint);
                shadowInsertionPoint = toHTMLShadowElement(point);
                shadowInsertionPoints.append(shadowInsertionPoint);
            } else {
                pool.distributeTo(point, this);
                if (ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*point))
                    shadow->setNeedsDistributionRecalc();
            }
        }
    }

    for (size_t i = shadowInsertionPoints.size(); i > 0; --i) {
        HTMLShadowElement* shadowInsertionPoint = shadowInsertionPoints[i - 1];
        ShadowRoot* root = shadowInsertionPoint->containingShadowRoot();
        ASSERT(root);
        if (root->isOldest()) {
            pool.distributeTo(shadowInsertionPoint, this);
        } else if (root->olderShadowRoot()->type() == root->type()) {
            // Only allow reprojecting older shadow roots between the same type to
            // disallow reprojecting UA elements into author shadows.
            DistributionPool olderShadowRootPool(*root->olderShadowRoot());
            olderShadowRootPool.distributeTo(shadowInsertionPoint, this);
            root->olderShadowRoot()->setShadowInsertionPointOfYoungerShadowRoot(shadowInsertionPoint);
        }
        if (ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*shadowInsertionPoint))
            shadow->setNeedsDistributionRecalc();
    }
    InspectorInstrumentation::didPerformElementShadowDistribution(host());
}
开发者ID:mtucker6784,项目名称:chromium,代码行数:43,代码来源:ElementShadow.cpp

示例6: TEST

TEST(ResStringPool, AppendToExistingUTF16) {
  const std::array<uint8_t, 116> data{{
      0x01, 0x00, 0x1C, 0x00, 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00,
      0x1C, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
      0x05, 0x00, 0x63, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x72, 0x00,
      0x00, 0x00, 0x05, 0x00, 0x64, 0x00, 0x69, 0x00, 0x6D, 0x00, 0x65, 0x00,
      0x6E, 0x00, 0x00, 0x00, 0x02, 0x00, 0x69, 0x00, 0x64, 0x00, 0x00, 0x00,
      0x06, 0x00, 0x6C, 0x00, 0x61, 0x00, 0x79, 0x00, 0x6F, 0x00, 0x75, 0x00,
      0x74, 0x00, 0x00, 0x00, 0x06, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00,
      0x69, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x00, 0x00}};
  android::ResStringPool pool(&data, data.size(), false);
  ASSERT_TRUE(!pool.isUTF8());
  size_t out_len;
  auto s = pool.stringAt(0, &out_len);
  assert_u16_string(s, "color");
  ASSERT_EQ(out_len, 5);

  // Make sure the size encoding works for large values.
  auto big_string = make_big_string(35000);
  auto big_chars = big_string.c_str();
  pool.appendString(android::String8(big_chars));
  pool.appendString(android::String8("more more more"));
  android::Vector<char> v;
  pool.serialize(v);
  android::ResStringPool after((void*)v.array(), v.size(), false);

  assert_u16_string(after.stringAt(0, &out_len), "color");
  ASSERT_EQ(out_len, 5);
  assert_u16_string(after.stringAt(1, &out_len), "dimen");
  ASSERT_EQ(out_len, 5);
  assert_u16_string(after.stringAt(2, &out_len), "id");
  ASSERT_EQ(out_len, 2);
  assert_u16_string(after.stringAt(3, &out_len), "layout");
  ASSERT_EQ(out_len, 6);
  assert_u16_string(after.stringAt(4, &out_len), "string");
  ASSERT_EQ(out_len, 6);
  assert_u16_string(after.stringAt(5, &out_len), big_chars);
  ASSERT_EQ(out_len, 35000);
  assert_u16_string(after.stringAt(6, &out_len), "more more more");
  ASSERT_EQ(out_len, 14);
}
开发者ID:JoelMarcey,项目名称:redex,代码行数:43,代码来源:ResourceSerializationTest.cpp

示例7: main

int main()
{
    stxxl::prefetch_pool<block_type> pool(2);
    pool.resize(10);
    pool.resize(5);

    block_type* blk = new block_type;
    (*blk)[0].integer = 42;
    block_type::bid_type bids[2];
    stxxl::block_manager::get_instance()->new_blocks(stxxl::single_disk(), bids, bids + 2);
    blk->write(bids[0])->wait();
    blk->write(bids[1])->wait();

    pool.hint(bids[0]);
    pool.read(blk, bids[0])->wait();
    pool.read(blk, bids[1])->wait();

    delete blk;
}
开发者ID:ConfusedReality,项目名称:pkg_template_stxxl,代码行数:19,代码来源:test_prefetch_pool.cpp

示例8: DEF_TEST

/**
 *  This tests the basic functionality of SkDiscardablePixelRef with a
 *  basic SkImageGenerator implementation and several
 *  SkDiscardableMemory::Factory choices.
 */
DEF_TEST(DiscardableAndCachingPixelRef, reporter) {
    check_pixelref(TestImageGenerator::kFailGetPixels_TestType, reporter, nullptr);
    check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, reporter, nullptr);

    SkAutoTUnref<SkDiscardableMemoryPool> pool(
        SkDiscardableMemoryPool::Create(1, nullptr));
    REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
    check_pixelref(TestImageGenerator::kFailGetPixels_TestType, reporter, pool);
    REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());
    check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, reporter, pool);
    REPORTER_ASSERT(reporter, 0 == pool->getRAMUsed());

    SkDiscardableMemoryPool* globalPool = SkGetGlobalDiscardableMemoryPool();
    // Only acts differently from nullptr on a platform that has a
    // default discardable memory implementation that differs from the
    // global DM pool.
    check_pixelref(TestImageGenerator::kFailGetPixels_TestType, reporter, globalPool);
    check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType, reporter, globalPool);
}
开发者ID:Just-D,项目名称:skia,代码行数:24,代码来源:CachedDecodingPixelRefTest.cpp

示例9: testAPCSum

static void testAPCSum() {
  DigitPool pool(-5);
  for(;;) {
    const FullFormatBigReal x = inputBigReal(pool, _T("Enter x:"));
    const FullFormatBigReal y = inputBigReal(pool, _T("Enter y:"));
    _tprintf(_T("Enter bias ('<','>','#'):"));
    char bias = getchar();
    FullFormatBigReal p = BigReal::apcSum(bias, x, y, &pool);

    _tprintf(_T("x:%50s y:%50s\n"), x.toString().cstr(), y.toString().cstr());
    _tprintf(_T("APCSum(>,x,y) = %s\n"), p.toString().cstr());

    try {
      p.assertIsValidBigReal();
    } catch(Exception e) {
      _tprintf(_T("%s\n"), e.what());
    }
  }
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:19,代码来源:main.cpp

示例10: testShortProd

static void testShortProd() {
  DigitPool pool(-5);
//  for(;;) {
//    int useReferenceVersion = inputInt(_T("Use reference version (1=reference, 2=debug"));

//    BigReal::setUseShortProdRefenceVersion(useReferenceVersion == 1);

//    float maxError32Ref = getRelativeError32(FLT_MIN,&pool);
//    BigReal::setUseShortProdRefenceVersion(false);
//    float maxError32FPU = getRelativeError32(FLT_MIN,&pool);
//    BigReal::setUseShortProdRefenceVersion(true);

    const FullFormatBigReal x = BigReal(spaceString(14700,'9')); // inputBigReal(pool, _T("Enter x:"));
    const FullFormatBigReal y = BigReal(spaceString(14700,'9')); // inputBigReal(pool, _T("Enter y:"));

    _tprintf(_T("X:%s\nY:%s\n"), x.toString().cstr(), y.toString().cstr());

    FullFormatBigReal p1(&pool), p2(&pool);

    p1 = BigReal::shortProd(x, y, BIGREAL_0, &pool);

    _tprintf(_T("p1:%s\n"), p1.toString().cstr());

    BigReal::setUseShortProdRefenceVersion(false);

    p2 = BigReal::shortProd(x, y, BIGREAL_0, &pool);

    BigReal::setUseShortProdRefenceVersion(true);

    _tprintf(_T("p2:%s\n"), p2.toString().cstr());

    try {
      p1.assertIsValidBigReal();
    } catch(Exception e) {
      _tprintf(_T("p1 failed:%s\n"), e.what());
    }
    try {
      p2.assertIsValidBigReal();
    } catch(Exception e) {
      _tprintf(_T("p2 failed:%s\n"), e.what());
    }
//  }
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:43,代码来源:main.cpp

示例11: LoadTable

void LoadTable() {
  const oid_t col_count = state.attribute_count + 1;
  const int tuple_count = state.scale_factor * state.tuples_per_tilegroup;

  auto table_schema = sdbench_table->GetSchema();

  /////////////////////////////////////////////////////////
  // Load in the data
  /////////////////////////////////////////////////////////

  // Insert tuples into tile_group.
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
  const bool allocate = true;
  auto txn = txn_manager.BeginTransaction();
  std::unique_ptr<type::AbstractPool> pool(new type::EphemeralPool());

  std::unique_ptr<executor::ExecutorContext> context(
      new executor::ExecutorContext(txn));

  for (int rowid = 0; rowid < tuple_count; rowid++) {
    int populate_value = rowid;

    std::unique_ptr<storage::Tuple> tuple(new storage::Tuple(table_schema, allocate));

    for (oid_t col_itr = 0; col_itr < col_count; col_itr++) {
      auto value = type::ValueFactory::GetIntegerValue(populate_value);
      tuple->SetValue(col_itr, value, pool.get());
    }

    planner::InsertPlan node(sdbench_table.get(), std::move(tuple));
    executor::InsertExecutor executor(&node, context.get());
    executor.Execute();
  }

  auto result = txn_manager.CommitTransaction(txn);

  if (result == ResultType::SUCCESS) {
    LOG_TRACE("commit successfully");
  } else {
    LOG_TRACE("commit failed");
  }
}
开发者ID:wy4515,项目名称:peloton,代码行数:42,代码来源:sdbench_loader.cpp

示例12: main

int main( int argc, char *argv[])
{
	try
	{
		tsk::static_pool< tsk::unbounded_prio_queue< int > > pool( tsk::poolsize( 3) ); 

		tsk::task< int > t1( fibonacci_fn, 10);
		tsk::task< int > t2( fibonacci_fn, 10);
		tsk::task< int > t3( fibonacci_fn, 10);
		tsk::task< int > t4( fibonacci_fn, 10);

		tsk::handle< int > h1(
			tsk::async( boost::move( t1) ) );
		tsk::handle< int > h2(
			tsk::async(
				boost::move( t2),
				tsk::new_thread() ) );
		tsk::handle< int > h3(
			tsk::async(
				boost::move( t3),
				2,
				pool) );
		tsk::handle< int > h4(
			tsk::async(
				boost::move( t4),
				2,
				pool) );

		std::cout << h1.get() << std::endl;
		std::cout << h2.get() << std::endl;
		std::cout << h3.get() << std::endl;
		std::cout << h4.get() << std::endl;

		return EXIT_SUCCESS;
	}
	catch ( std::exception const& e)
	{ std::cerr << "exception: " << e.what() << std::endl; }
	catch ( ... )
	{ std::cerr << "unhandled" << std::endl; }

	return EXIT_FAILURE;
}
开发者ID:novator24,项目名称:boost-task,代码行数:42,代码来源:submit.cpp

示例13: TEST

TEST(Parallel, mutexRegion) {
    uint32_t var = 0;
    lock_t mutex;

    auto threadFunc = [&var, &mutex](uint32_t idx){
        for (uint32_t i = 0; i < itCnt; i++) {
            mutex_begin(uqlk, mutex);
            var += idx;
            mutex_end();
        }
    };

    thread_pool_t pool(thCnt);
    for (uint32_t idx = 0; idx < thCnt; idx++) {
        pool.add_task(std::bind(threadFunc, idx));
    }
    pool.wait_all();

    ASSERT_EQ((0+7)*8/2 * itCnt, var);
}
开发者ID:gaomy3832,项目名称:utils,代码行数:20,代码来源:parallel_test.cpp

示例14: main

int main()
{
    ThreadPool pool(16);

    Test t;
    for(int i = 0; i < 10; i ++)
    {
        pool.put(boost::bind(&Test::doit, t, i));
    }

    pool.start(3);
    sleep(1);

    printf("new data\n");
    pool.put(boost::bind(&Test::doit, t, 21));
    pool.put(boost::bind(&Test::doit, t, 22));
    sleep(1);

    return 0;
}
开发者ID:leafji,项目名称:mywheetlib,代码行数:20,代码来源:TestThreadPool.cpp

示例15: test

	template <class T, class Func_T> void test(Test_Context& tc, Func_T func)
	{
		Node_Pool<T> pool(&m_context, 5);
		T* ptr[5];
		for(int i = 0; i < 5; ++i)
		{
			GTL_TEST_VERIFY(tc, !pool.empty());
			ptr[i] = pool.create(func);
			*ptr[i] =  i;
		}
			
		GTL_TEST_VERIFY(tc, pool.empty());
			
		//Read back and destroy
		for(int i = 0; i < 5; ++i)
		{
			GTL_TEST_EQ(tc, (int) *ptr[i], i);
			pool.destroy(ptr[i]);
		}
	}
开发者ID:kevinic,项目名称:gtl,代码行数:20,代码来源:pool.cpp


注:本文中的pool函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。