2#include <condition_variable>
5#include "../api_status.h"
7namespace cl::threading {
23 std::condition_variable cond;
35 std::lock_guard<std::mutex> lock{ mtx };
36 q.push_front(std::move(item));
54 cl::api_status
pop(T* next) {
56 std::unique_lock<std::mutex> lock{ mtx };
57 this->cond.wait(lock, [
this](){
58 return closed || !this->q.empty();
63 return api_status::no_result;
67 *next = std::move(q.back());
69 return api_status::ok;
91 std::lock_guard<std::mutex> lock{ mtx };
A thread-safe blocking concurrent queue.
Definition: blocking_queue.h:20
size_t workload_count() const
Returns the current workload count.
Definition: blocking_queue.h:76
void close()
close the queue
Definition: blocking_queue.h:88
cl::api_status pop(T *next)
Pops an item from the queue.
Definition: blocking_queue.h:54
void push(T &&item)
Pushes a new item to the queue, under a lock.
Definition: blocking_queue.h:32