mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-14 15:55:07 +00:00
util-threadpool: Fix rare double-execute bug
This commit is contained in:
parent
7fbbd39bf5
commit
05d69e3c59
1 changed files with 3 additions and 3 deletions
|
@ -51,15 +51,15 @@ void util::threadpool::push(threadpool_function_t fn, std::shared_ptr<void> data
|
||||||
|
|
||||||
void util::threadpool::work()
|
void util::threadpool::work()
|
||||||
{
|
{
|
||||||
|
while (!_worker_stop) {
|
||||||
std::pair<threadpool_function_t, std::shared_ptr<void>> work;
|
std::pair<threadpool_function_t, std::shared_ptr<void>> work;
|
||||||
|
|
||||||
while (!_worker_stop) {
|
|
||||||
// Wait for more work, or immediately continue if there is still work to do.
|
// Wait for more work, or immediately continue if there is still work to do.
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(_tasks_lock);
|
std::unique_lock<std::mutex> lock(_tasks_lock);
|
||||||
if (_tasks.size() == 0)
|
if (_tasks.size() == 0)
|
||||||
_tasks_cv.wait(lock, [this]() { return _worker_stop || _tasks.size() > 0; });
|
_tasks_cv.wait(lock, [this]() { return _worker_stop || _tasks.size() > 0; });
|
||||||
if (_tasks.size() == 0)
|
if (_worker_stop || (_tasks.size() == 0))
|
||||||
continue;
|
continue;
|
||||||
work = _tasks.front();
|
work = _tasks.front();
|
||||||
_tasks.pop_front();
|
_tasks.pop_front();
|
||||||
|
|
Loading…
Reference in a new issue