Changeset 845

Show
Ignore:
Timestamp:
01/17/08 20:20:29
Author:
robert
Message:

Added throttling of the calls to ThreadPool?::run to limit the number of operations
that the queue will permit.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/vpb/ThreadPool

    r807 r845  
    7272        bool                                _done; 
    7373        osg::ref_ptr<BlockOperation>        _blockOp; 
     74         
     75        unsigned int                         _maxNumberOfOperationsInQueue; 
    7476        
    7577}; 
  • trunk/src/vpb/ThreadPool.cpp

    r808 r845  
    4545 
    4646    osg::GraphicsContext* sharedContext = 0; 
     47 
     48    _maxNumberOfOperationsInQueue = 512; 
    4749 
    4850    for(unsigned int i=0; i<_numThreads; ++i) 
     
    143145    } 
    144146     
     147    while (_operationQueue->getNumOperationsInQueue() >= _maxNumberOfOperationsInQueue) 
     148    { 
     149        log(osg::NOTICE,"ThreadPool::run() Waiting for operation queue to clear."); 
     150        OpenThreads::Thread::YieldCurrentThread(); 
     151    } 
     152     
    145153    _operationQueue->add(op); 
    146154}