本文整理汇总了C++中ThreadPool::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadPool::Create方法的具体用法?C++ ThreadPool::Create怎么用?C++ ThreadPool::Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThreadPool
的用法示例。
在下文中一共展示了ThreadPool::Create方法的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 );
}
示例2: 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;
}
示例3: main
int main(int argc, char * argv[])
{
printf("starting: %u\n", 4);
ThreadPool<4> p;
p.Create(thread_start, 0);
;;; //////
p.WaitForTerminate();
exit(EXIT_SUCCESS);
}
示例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;
}