MCPcopy Create free account
hub / github.com/ChiyukiGana/Quickinput / enqueue

Method enqueue

source/src/tools/threadqueue.h:46–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45 template<class Fn, class... Args>
46 std::future<std::invoke_result_t<Fn, Args...>> enqueue(Fn&& fn, Args&&... args)
47 {
48 if (stop) throw std::runtime_error("ThreadQueue::enqueue: this thread-queue is stopped");
49 auto task = std::make_shared<std::packaged_task<std::invoke_result_t<Fn, Args...>()>>(std::bind(std::forward<Fn>(fn), std::forward<Args>(args)...));
50 std::future<std::invoke_result_t<Fn, Args...>> result = task->get_future();
51 {
52 std::unique_lock<std::mutex> lock(mutex);
53 queue.emplace([task] { (*task)(); });
54 }
55 condition.notify_one();
56 return result;
57 }
58 bool stopped() const
59 {
60 return stop;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected