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


C++ ThreadPool::Start方法代码示例

本文整理汇总了C++中ThreadPool::Start方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadPool::Start方法的具体用法?C++ ThreadPool::Start怎么用?C++ ThreadPool::Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ThreadPool的用法示例。


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

示例1: AtomicTest

void AtomicTest( void )
{
    char ender;

    cout << "Starting Loki::Printf AtomicTest" << endl;
    {
        ThreadPool pool;
        pool.Create( 20, &DoLokiPrintfLoop );
        pool.Start();
        pool.Join();
    }
    cout << "Finished Loki::Printf AtomicTest." << endl;
	cout << "If the output lines up in neat columns, the test passed." << endl;
	cout << "If the output is not in columns, then the test failed." << endl;
    cout << "Press <Enter> key to continue. ";
    cin.get( ender );

    cout << "Starting Loki::FPrintf AtomicTest" << endl;
    {
        ThreadPool pool;
        pool.Create( 20, &DoLokiFPrintfLoop );
        pool.Start();
        pool.Join();
    }
    cout << "Finished Loki::FPrintf AtomicTest." << endl;
	cout << "If the output lines up in neat columns, the test passed." << endl;
	cout << "If the output is not in columns, then the test failed." << endl;
    cout << "Press <Enter> key to continue. ";
    cin.get( ender );

    cout << "Starting stdout AtomicTest" << endl;
    {
        ThreadPool pool;
        pool.Create( 20, &DoStdOutLoop );
        pool.Start();
        pool.Join();
    }
    cout << "Finished stdout AtomicTest." << endl;
	cout << "If the output lines up in neat columns, your compiler implements printf correctly." << endl;
	cout << "If the output is not in columns, then your compiler implements printf incorrectly." << endl;
    cout << "Press <Enter> key to continue. ";
    cin.get( ender );

    cout << "Starting cout AtomicTest" << endl;
    {
        ThreadPool pool;
        pool.Create( 20, &DoCoutLoop );
        pool.Start();
        pool.Join();
    }
    cout << "Finished cout AtomicTest." << endl;
	cout << "If the output lines up in neat columns, your compiler implements cout correctly." << endl;
	cout << "If the output is not in columns, then your compiler implements cout incorrectly." << endl;
    cout << "Press <Enter> key to continue. ";
    cin.get( ender );
}
开发者ID:AFialkovskiy,项目名称:loki-lib,代码行数:56,代码来源:main.cpp

示例2: main

int main(int argc, char **argv){

	bool ret = true;

	long size = sysconf(_SC_NPROCESSORS_ONLN);
	cout<<"number of workers: "<<size<<endl;

	ThreadPool p;

	ret = p.Init(size, start_routine, arg);
	if (!ret){
		return -1;
	}

	ret = p.Start();
	if (!ret){
		p.Shutdown();
		return -1;
	}

	int n = 3;
	while(n-->0){
		sleep(2);
	}
	p.Shutdown();

	return 0;
}
开发者ID:ongonginging,项目名称:demo,代码行数:28,代码来源:Test_ThreadPool.cpp

示例3: DoObjectLockTest

void DoObjectLockTest( void )
{
    cout << "Starting DoObjectLockTest" << endl;

    LockableObjects & objects = GetLockableObjects();
    objects.reserve( ObjectCount );
    for ( unsigned int ii = 0; ii < ObjectCount; ++ii )
    {
        LockableObject * object = new LockableObject( ii );
        objects.push_back( object );
    }

    {
        ThreadPool pool;
        pool.Create( ThreadCount, &RunObjectTest );
        pool.Start();
        pool.Join();
    }

    unsigned int totalFails = 0;
    for ( unsigned int ii = 0; ii < ThreadCount; ++ii )
    {
        const unsigned int failCount = FailCounts[ ii ];
        ::Loki::Printf( "Thread: [%u]  Failures: [%u]\n" )( ii )( failCount );
        totalFails += failCount;
    }
    const char * result = ( 0 == totalFails ) ? "Passed" : "FAILED";

    cout << "Finished DoObjectLockTest.  Total Fails: " << totalFails << "  Result: "
        << result << endl;
}
开发者ID:JackieXie168,项目名称:loki,代码行数:31,代码来源:main.cpp

示例4: DoClassLockTest

void DoClassLockTest( void )
{
    cout << "Starting DoClassLockTest" << endl;

    LockableClasses & objects = GetLockableClasses();
    objects.reserve( ClassCount );
    for ( unsigned int ii = 0; ii < ClassCount; ++ii )
    {
        LockableClass * object = new LockableClass( ii );
        objects.push_back( object );
    }

    {
        ThreadPool pool;
        pool.Create( ThreadCount, &RunClassTest );
        pool.Start();
        pool.Join();
    }

    cout << "Finished DoClassLockTest" << endl;
}
开发者ID:JackieXie168,项目名称:loki,代码行数:21,代码来源:main.cpp


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