Browse Source
Merge pull request #9966 from bunnei/bounded-polyfill
common: bounded_threadsafe_queue: Use polyfill_thread.
pull/15/merge
liamwhite
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
3 additions and
2 deletions
-
src/common/bounded_threadsafe_queue.h
|
|
|
@ -9,10 +9,11 @@ |
|
|
|
#include <memory> |
|
|
|
#include <mutex> |
|
|
|
#include <new> |
|
|
|
#include <stop_token> |
|
|
|
#include <type_traits> |
|
|
|
#include <utility> |
|
|
|
|
|
|
|
#include "common/polyfill_thread.h" |
|
|
|
|
|
|
|
namespace Common { |
|
|
|
|
|
|
|
#if defined(__cpp_lib_hardware_interference_size) |
|
|
|
@ -78,7 +79,7 @@ public: |
|
|
|
auto& slot = slots[idx(tail)]; |
|
|
|
if (!slot.turn.test()) { |
|
|
|
std::unique_lock lock{cv_mutex}; |
|
|
|
cv.wait(lock, stop, [&slot] { return slot.turn.test(); }); |
|
|
|
Common::CondvarWait(cv, lock, stop, [&slot] { return slot.turn.test(); }); |
|
|
|
} |
|
|
|
v = slot.move(); |
|
|
|
slot.destroy(); |
|
|
|
|