6 #include <condition_variable> 15 std::condition_variable
cv;
22 std::unique_lock<std::mutex> lock(mutex);
23 q.push(std::move(item));
30 std::unique_lock<std::mutex> lock(mutex);
31 const auto ready = [
this]() {
return !q.empty(); };
32 if (!ready() && !cv.wait_for(lock,
std::chrono::seconds(5), ready))
throw std::runtime_error(
"Timeout waiting for queued items!");
33 auto item = std::move(q.front());
35 return std::move(item);
40 std::unique_lock<std::mutex> lock(mutex);
43 auto val = std::move(q.front());
45 *item = std::move(
val);
53 std::unique_lock<std::mutex> lock(mutex);
56 const auto ready = [
this]() {
return !q.empty(); };
57 if (!ready() && !cv.wait_for(lock,
std::chrono::seconds(5), ready))
throw std::runtime_error(
"Timeout waiting for queued items!");
58 auto item = std::move(q.front());
66 std::unique_lock<std::mutex> lock(mutex);
73 for (
auto is_running : running)
bool try_dequeue(T *item)
std::condition_variable cv
bool any_costumers_alive(const std::vector< bool > &running)