MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / enqueue

Method enqueue

framework/ThreadPool/ThreadPool.h:68–80  ·  view source on GitHub ↗

add new work item to the pool

Source from the content-addressed store, hash-verified

66
67// add new work item to the pool
68void ThreadPool::enqueue(std::function<void()> task)
69{
70 {
71 std::unique_lock<std::mutex> lock(queue_mutex);
72
73 // don't allow enqueueing after stopping the pool
74 if (stop)
75 throw std::runtime_error("enqueue on stopped ThreadPool");
76
77 tasks.emplace(task);
78 }
79 condition.notify_one();
80}
81
82// the destructor joins all threads
83inline ThreadPool::~ThreadPool()

Callers 1

threadPoolTaskEnqueueMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected