MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / ThreadPool

Method ThreadPool

Engine/source/platform/threads/threadPool.cpp:320–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318//--------------------------------------------------------------------------
319
320ThreadPool::ThreadPool( const char* name, U32 numThreads )
321 : mName( name ),
322 mNumThreads( numThreads ),
323 mNumThreadsAwake( 0 ),
324 mNumPendingItems( 0 ),
325 mThreads( 0 ),
326 mSemaphore( 0 )
327{
328 // Number of worker threads to create.
329
330 if( !mNumThreads )
331 {
332 // Use platformCPUInfo directly as in the case of the global pool,
333 // Platform::SystemInfo will not yet have been initialized.
334
335 U32 numLogical = 0;
336 U32 numPhysical = 0;
337 U32 numCores = 0;
338
339 CPUInfo::CPUCount( numLogical, numCores, numPhysical );
340
341 const U32 baseCount = getMax( numLogical, numCores );
342 mNumThreads = (baseCount > 0) ? baseCount : 2;
343 }
344
345 #ifdef DEBUG_SPEW
346 Platform::outputDebugString( "[ThreadPool] spawning %i threads", mNumThreads );
347 #endif
348
349 // Create the threads.
350
351 mNumThreadsAwake = mNumThreads;
352 mNumThreadsReady = mNumThreads;
353 for( U32 i = 0; i < mNumThreads; i ++ )
354 {
355 WorkerThread* thread = new WorkerThread( this, i );
356 thread->start();
357 }
358}
359
360//--------------------------------------------------------------------------
361

Callers

nothing calls this directly

Calls 3

getMaxFunction · 0.85
CPUCountFunction · 0.50
startMethod · 0.45

Tested by

no test coverage detected