From Matthew Johnson-Roberson, "Small fix for operation thread to protect the access to _operations vector by functions getNumOperationsInQueue() and empty(). It is simply an addition of OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_operationsMutex);
to protect against accessing while writing which was segfaulting in VPB specifically in void ThreadPool::run(osg::Operation* op) in the waiting loop while (_operationQueue->getNumOperationsInQueue() >= _maxNumberOfOperationsInQueue) "
This commit is contained in:
parent
2dc0247bd9
commit
6d1944b9e2
@ -105,10 +105,10 @@ class OSG_EXPORT OperationQueue : public Referenced
|
|||||||
osg::ref_ptr<Operation> getNextOperation(bool blockIfEmpty = false);
|
osg::ref_ptr<Operation> getNextOperation(bool blockIfEmpty = false);
|
||||||
|
|
||||||
/** Return true if the operation queue is empty. */
|
/** Return true if the operation queue is empty. */
|
||||||
bool empty() const { return _operations.empty(); }
|
bool empty();
|
||||||
|
|
||||||
/** Return the num of pending operations that are sitting in the OperationQueue.*/
|
/** Return the num of pending operations that are sitting in the OperationQueue.*/
|
||||||
unsigned int getNumOperationsInQueue() const { return static_cast<unsigned int>(_operations.size()); }
|
unsigned int getNumOperationsInQueue();
|
||||||
|
|
||||||
/** Add operation to end of OperationQueue, this will be
|
/** Add operation to end of OperationQueue, this will be
|
||||||
* executed by the operation thread once this operation gets to the head of the queue.*/
|
* executed by the operation thread once this operation gets to the head of the queue.*/
|
||||||
|
@ -55,6 +55,19 @@ OperationQueue::~OperationQueue()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OperationQueue::empty()
|
||||||
|
{
|
||||||
|
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_operationsMutex);
|
||||||
|
return _operations.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int OperationQueue::getNumOperationsInQueue()
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_operationsMutex);
|
||||||
|
return static_cast<unsigned int>(_operations.size());
|
||||||
|
}
|
||||||
|
|
||||||
ref_ptr<Operation> OperationQueue::getNextOperation(bool blockIfEmpty)
|
ref_ptr<Operation> OperationQueue::getNextOperation(bool blockIfEmpty)
|
||||||
{
|
{
|
||||||
if (blockIfEmpty && _operations.empty())
|
if (blockIfEmpty && _operations.empty())
|
||||||
|
Loading…
Reference in New Issue
Block a user