mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-06 11:15:53 +00:00
Another race condition fix
This commit is contained in:
parent
5fc5442286
commit
6945ec94b8
@ -17,6 +17,7 @@ class ClientProcess
|
||||
std::mutex m_mutex;
|
||||
std::condition_variable m_cv;
|
||||
std::condition_variable m_initCv;
|
||||
std::condition_variable m_waitCv;
|
||||
int m_verbosity;
|
||||
|
||||
public:
|
||||
@ -87,6 +88,7 @@ public:
|
||||
const LambdaTransaction* addLambdaTransaction(std::function<void(BlenderToken&)>&& func);
|
||||
bool syncCook(const hecl::ProjectPath& path, Database::IDataSpec* spec, BlenderToken& btok);
|
||||
void swapCompletedQueue(std::list<std::unique_ptr<Transaction>>& queue);
|
||||
void waitUntilComplete();
|
||||
void shutdown();
|
||||
};
|
||||
|
||||
|
@ -77,6 +77,7 @@ void ClientProcess::Worker::proc()
|
||||
lk.lock();
|
||||
m_proc.m_completedQueue.push_back(std::move(trans));
|
||||
}
|
||||
m_proc.m_waitCv.notify_one();
|
||||
if (!m_proc.m_running)
|
||||
break;
|
||||
m_proc.m_cv.wait(lk);
|
||||
@ -154,6 +155,13 @@ void ClientProcess::swapCompletedQueue(std::list<std::unique_ptr<Transaction>>&
|
||||
queue.swap(m_completedQueue);
|
||||
}
|
||||
|
||||
void ClientProcess::waitUntilComplete()
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(m_mutex);
|
||||
while (m_pendingQueue.size())
|
||||
m_waitCv.wait(lk);
|
||||
}
|
||||
|
||||
void ClientProcess::shutdown()
|
||||
{
|
||||
if (!m_running)
|
||||
|
Loading…
x
Reference in New Issue
Block a user