| 445 | } |
| 446 | |
| 447 | void ThreadPool::waitForAllItems( S32 timeOut ) |
| 448 | { |
| 449 | U32 endTime = 0; |
| 450 | if( timeOut != -1 ) |
| 451 | endTime = Platform::getRealMilliseconds() + timeOut; |
| 452 | |
| 453 | // Spinlock until there are no items that have not been processed. |
| 454 | |
| 455 | while( dAtomicRead( mNumPendingItems ) ) |
| 456 | { |
| 457 | Platform::sleep( 25 ); |
| 458 | |
| 459 | // Stop if we have exceeded our processing time budget. |
| 460 | |
| 461 | if( timeOut != -1 |
| 462 | && Platform::getRealMilliseconds() >= endTime ) |
| 463 | break; |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | //-------------------------------------------------------------------------- |
| 468 | |