| 400 | //-------------------------------------------------------------------------- |
| 401 | |
| 402 | void ThreadPool::queueWorkItem( WorkItem* item ) |
| 403 | { |
| 404 | bool executeRightAway = ( getForceAllMainThread() ); |
| 405 | #ifdef DEBUG_SPEW |
| 406 | Platform::outputDebugString( "[ThreadPool] %s work item '0x%x'", |
| 407 | ( executeRightAway ? "executing" : "queuing" ), |
| 408 | item ); |
| 409 | #endif |
| 410 | |
| 411 | if( executeRightAway ) |
| 412 | item->process(); |
| 413 | else |
| 414 | { |
| 415 | // Put the item in the queue. |
| 416 | dFetchAndAdd( mNumPendingItems, 1 ); |
| 417 | mWorkItemQueue.insert( item->getPriority(), item ); |
| 418 | |
| 419 | mSemaphore.release(); |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | //-------------------------------------------------------------------------- |
| 424 | |