Minor refactorings
UDPC_update now locks the mutex to keep it thread-safe.
This commit is contained in:
parent
ffcc30bc64
commit
1af44db109
1 changed files with 5 additions and 3 deletions
|
@ -1784,9 +1784,10 @@ void UDPC::threadedUpdate(Context *ctx) {
|
||||||
decltype(now) nextNow;
|
decltype(now) nextNow;
|
||||||
while(ctx->threadRunning.load()) {
|
while(ctx->threadRunning.load()) {
|
||||||
now = std::chrono::steady_clock::now();
|
now = std::chrono::steady_clock::now();
|
||||||
ctx->mutex.lock();
|
{
|
||||||
ctx->update_impl();
|
std::lock_guard<std::mutex> lock(ctx->mutex);
|
||||||
ctx->mutex.unlock();
|
ctx->update_impl();
|
||||||
|
}
|
||||||
nextNow = std::chrono::steady_clock::now();
|
nextNow = std::chrono::steady_clock::now();
|
||||||
std::this_thread::sleep_for(ctx->threadedSleepTime - (nextNow - now));
|
std::this_thread::sleep_for(ctx->threadedSleepTime - (nextNow - now));
|
||||||
}
|
}
|
||||||
|
@ -2075,6 +2076,7 @@ void UDPC_update(UDPC_HContext ctx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(c->mutex);
|
||||||
c->update_impl();
|
c->update_impl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue