mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 21:40:42 +00:00
Race condition fix
This commit is contained in:
parent
35b2d91fb3
commit
9c86d4f8bc
@ -25,6 +25,7 @@ void WorkTicket::signalDone()
|
|||||||
WorkItem::WorkItem()
|
WorkItem::WorkItem()
|
||||||
: mTicket(new WorkTicket)
|
: mTicket(new WorkTicket)
|
||||||
{
|
{
|
||||||
|
mTicket->setThreadSafeRefUnref(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkItem::~WorkItem()
|
WorkItem::~WorkItem()
|
||||||
@ -73,9 +74,9 @@ WorkQueue::~WorkQueue()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkTicket* WorkQueue::addWorkItem(WorkItem *item)
|
osg::ref_ptr<WorkTicket> WorkQueue::addWorkItem(WorkItem *item)
|
||||||
{
|
{
|
||||||
WorkTicket* ticket = item->getTicket().get();
|
osg::ref_ptr<WorkTicket> ticket = item->getTicket();
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mMutex);
|
||||||
mQueue.push(item);
|
mQueue.push(item);
|
||||||
mCondition.signal();
|
mCondition.signal();
|
||||||
|
@ -65,7 +65,7 @@ namespace SceneUtil
|
|||||||
|
|
||||||
/// Add a new work item to the back of the queue.
|
/// Add a new work item to the back of the queue.
|
||||||
/// @par The returned WorkTicket may be used by the caller to wait until the work is complete.
|
/// @par The returned WorkTicket may be used by the caller to wait until the work is complete.
|
||||||
WorkTicket* addWorkItem(WorkItem* item);
|
osg::ref_ptr<WorkTicket> addWorkItem(WorkItem* item);
|
||||||
|
|
||||||
/// Get the next work item from the front of the queue. If the queue is empty, waits until a new item is added.
|
/// Get the next work item from the front of the queue. If the queue is empty, waits until a new item is added.
|
||||||
/// If the workqueue is in the process of being destroyed, may return NULL.
|
/// If the workqueue is in the process of being destroyed, may return NULL.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user