20 #include <condition_variable>
57 bool pop(T &dest, uint32_t msecs);
99 std::lock_guard<std::mutex> lock(mutex);
100 queue.push(std::move(data));
101 increase.notify_all();
104 template <
typename T>
107 std::unique_lock<std::mutex> lock(mutex);
116 decrease.notify_all();
120 template <
typename T>
123 std::unique_lock<std::mutex> lock(mutex);
125 if (queue.empty() && increase.wait_for(lock, std::chrono::milliseconds(msecs)) == std::cv_status::timeout)
133 decrease.notify_all();
137 template <
typename T>
140 std::unique_lock<std::mutex> lock(mutex);
144 template <
typename T>
148 std::unique_lock<std::mutex> lock(mutex);
150 decrease.notify_all();
153 template <
typename T>
156 std::unique_lock<std::mutex> lock(mutex);
157 decrease.wait(lock, [
this]()
159 return queue.empty();
163 template <
typename T>
166 std::unique_lock<std::mutex> lock(mutex);
167 return decrease.wait_for(lock, std::chrono::milliseconds(msecs), [
this]()
169 return queue.empty();
173 template <
typename T>
177 std::unique_lock<std::mutex> lock(mutex);
179 increase.notify_all();
180 decrease.notify_all();
The UniqueQueue class is a thread-safe FIFO container adapter.
bool pop(T &dest, uint32_t msecs)
Pop data from queue.
void push(T &&data)
Move data to queue.
bool pop(T &dest)
Pop data from queue.
std::condition_variable increase
std::condition_variable decrease
void waitForEmpty() const
Wait for an empty queue.
void abort()
Clear queue and exit pop methods with false return.
size_t size() const
Return the number of items in the queue.
bool waitForEmpty(uint32_t msecs) const
Wait for an empty queue.
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects