mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Stop engine work queue before destructing environment
To avoid access to null and dangling pointers from active work items on quitting.
This commit is contained in:
parent
f8e02000ec
commit
f7a6be053d
3 changed files with 21 additions and 4 deletions
|
@ -33,14 +33,25 @@ bool WorkItem::isDone() const
|
|||
return mDone;
|
||||
}
|
||||
|
||||
WorkQueue::WorkQueue(int workerThreads)
|
||||
WorkQueue::WorkQueue(std::size_t workerThreads)
|
||||
: mIsReleased(false)
|
||||
{
|
||||
for (int i=0; i<workerThreads; ++i)
|
||||
mThreads.emplace_back(std::make_unique<WorkThread>(*this));
|
||||
start(workerThreads);
|
||||
}
|
||||
|
||||
WorkQueue::~WorkQueue()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
void WorkQueue::start(std::size_t workerThreads)
|
||||
{
|
||||
while (mThreads.size() < workerThreads)
|
||||
mThreads.emplace_back(std::make_unique<WorkThread>(*this));
|
||||
mIsReleased = false;
|
||||
}
|
||||
|
||||
void WorkQueue::stop()
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue