29 this->data =
other.data;
30 this->_notify_size =
other._notify_size;
31 this->_is_empty.store(
other._is_empty.load(std::memory_order_acquire), std::memory_order_release);
36 this->_is_empty.store(
source.empty(), std::memory_order_release);
39 bool empty()
const noexcept {
40 return this->_is_empty.load(std::memory_order_acquire);
44 std::lock_guard<std::mutex>
lock{ this->_lock };
45 return this->data.front();
57 void push_back(
T&&
item) {
58 std::lock_guard<std::mutex>
lock{ this->_lock };
59 this->data.push_back(std::move(
item));
60 this->_is_empty.store(
false, std::memory_order_release);
62 if (this->data.size() >= _notify_size) {
63 this->_cond.notify_all();
68 std::lock_guard<std::mutex>
lock{ this->_lock };
69 T item = std::move(data.front());
73 if (this->data.empty()) {
74 this->_is_empty.store(
true, std::memory_order_release);
89 std::unique_lock<std::mutex>
lock{ this->_lock };
90 this->_cond.wait(
lock, [
this] {
return this->data.size() >= _notify_size || !this->
is_waitable(); });
95 std::lock_guard<std::mutex>
lock{ this->_lock };
96 return this->data.size();
99 typename std::deque<T>::iterator begin()
noexcept {
100 return this->data.begin();
103 typename std::deque<T>::iterator end()
noexcept {
104 return this->data.end();
109 this->_is_waitable.store(
true, std::memory_order_release);
110 this->_cond.notify_all();
115 this->_is_waitable.store(
false, std::memory_order_release);
116 this->_cond.notify_all();
120 std::atomic<bool> _is_empty{
true };
121 std::atomic<bool> _is_waitable{
false };
123 mutable std::mutex _lock;
124 std::condition_variable _cond;