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

Method enqueue

source/src/tools/threadpool.h:50–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected