Merge 23de01a54b93e8d9a6efdabbca5c65a2b01dea65 into b7fdab15769d8a8cad14cc58213da3bdfa19fdf4

This commit is contained in:
TheMaverickProgrammer 2022-08-28 01:57:07 +09:00 committed by GitHub
commit d12eccd569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,7 +50,7 @@
Author Author
~~~~~~ ~~~~~~
David Barr, aka javidx9, ©OneLoneCoder 2019, 2020 David Barr, aka javidx9, ©OneLoneCoder 2019, 2020
*/ */
@ -109,7 +109,6 @@ namespace olc
std::scoped_lock lock(muxQueue); std::scoped_lock lock(muxQueue);
deqQueue.emplace_back(std::move(item)); deqQueue.emplace_back(std::move(item));
std::unique_lock<std::mutex> ul(muxBlocking);
cvBlocking.notify_one(); cvBlocking.notify_one();
} }
@ -118,8 +117,7 @@ namespace olc
{ {
std::scoped_lock lock(muxQueue); std::scoped_lock lock(muxQueue);
deqQueue.emplace_front(std::move(item)); deqQueue.emplace_front(std::move(item));
std::unique_lock<std::mutex> ul(muxBlocking);
cvBlocking.notify_one(); cvBlocking.notify_one();
} }
@ -146,10 +144,11 @@ namespace olc
void wait() void wait()
{ {
while (empty()) std::unique_lock<std::mutex> ul(muxQueue);
while (deqQueue.empty())
{ {
std::unique_lock<std::mutex> ul(muxBlocking); cvBlocking.wait(ul);
cvBlocking.wait(ul);
} }
} }
@ -157,7 +156,6 @@ namespace olc
std::mutex muxQueue; std::mutex muxQueue;
std::deque<T> deqQueue; std::deque<T> deqQueue;
std::condition_variable cvBlocking; std::condition_variable cvBlocking;
std::mutex muxBlocking;
}; };
} }
} }