5#include "webcface/common/webcface-config.h"
9#include <condition_variable>
21 std::condition_variable cond;
26 std::lock_guard lock(mtx);
31 std::lock_guard lock(mtx);
32 que.push(std::move(f));
36 std::lock_guard lock(mtx);
39 std::optional<T>
pop() {
40 std::lock_guard lock(mtx);
48 std::optional<T>
pop(std::chrono::milliseconds d) {
49 std::unique_lock lock(mtx);
50 if (cond.wait_for(lock, d, [&] { return !que.empty(); })) {
58 std::lock_guard lock(mtx);
59 std::queue<T>().swap(que);
排他制御をしたただのキュー
Definition queue.h:19
void push(const T &f)
Definition queue.h:25
bool empty()
Definition queue.h:35
std::optional< T > pop()
Definition queue.h:39
void clear()
Definition queue.h:57
void push(T &&f)
Definition queue.h:30
std::optional< T > pop(std::chrono::milliseconds d)
Definition queue.h:48
#define WEBCFACE_NS_END
Definition webcface-config.h:104
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:103