32 this->data =
other.data;
33 this->_notify_size =
other._notify_size;
34 this->_is_empty.store(
other._is_empty.load(std::memory_order_acquire), std::memory_order_release);
39 this->_is_empty.store(
source.empty(), std::memory_order_release);
42 bool empty()
const noexcept {
43 return this->_is_empty.load(std::memory_order_acquire);
47 std::lock_guard<std::mutex>
lock{ this->_lock };
48 return this->data.front();
60 void push_back(
T&&
item) {
61 std::lock_guard<std::mutex>
lock{ this->_lock };
62 this->data.push_back(std::move(
item));
63 this->_is_empty.store(
false, std::memory_order_release);
65 if (this->data.size() >= _notify_size) {
66 this->_cond.notify_all();
71 std::lock_guard<std::mutex>
lock{ this->_lock };
72 T item = std::move(data.front());
76 if (this->data.empty()) {
77 this->_is_empty.store(
true, std::memory_order_release);
92 std::unique_lock<std::mutex>
lock{ this->_lock };
93 this->_cond.wait(
lock, [
this] {
return this->data.size() >= _notify_size || !this->
is_waitable(); });
98 std::lock_guard<std::mutex>
lock{ this->_lock };
99 return this->data.size();
102 typename std::deque<T>::iterator begin()
noexcept {
103 return this->data.begin();
106 typename std::deque<T>::iterator end()
noexcept {
107 return this->data.end();
112 std::lock_guard<std::mutex>
lock{ this->_lock };
113 this->_is_waitable.store(
true, std::memory_order_release);
114 this->_cond.notify_all();
119 std::lock_guard<std::mutex>
lock{ this->_lock };
120 this->_is_waitable.store(
false, std::memory_order_release);
121 this->_cond.notify_all();
125 std::atomic<bool> _is_empty{
true };
126 std::atomic<bool> _is_waitable{
false };
128 mutable std::mutex _lock;
129 std::condition_variable _cond;