MCPcopy Create free account
hub / github.com/boostorg/asio / do_execute

Method do_execute

example/cpp14/executors/fork_join.cpp:121–137  ·  view source on GitHub ↗

Dispatch a function, executing it immediately if the queue is already loaded. Otherwise adds the function to the queue and wakes a thread.

Source from the content-addressed store, hash-verified

119 // Dispatch a function, executing it immediately if the queue is already
120 // loaded. Otherwise adds the function to the queue and wakes a thread.
121 void do_execute(std::shared_ptr<function_base> p,
122 const std::shared_ptr<std::size_t>& work_count)
123 {
124 std::unique_lock<std::mutex> lock(mutex_);
125 if (queue_.size() > thread_count_ * 16)
126 {
127 do_work_started(work_count);
128 lock.unlock();
129 execute(lock, p);
130 }
131 else
132 {
133 queue_.push(p);
134 do_work_started(work_count);
135 condition_.notify_one();
136 }
137 }
138
139 // Ask all threads to shut down.
140 void stop_threads()

Callers 1

executeMethod · 0.45

Calls 4

executeFunction · 0.50
sizeMethod · 0.45
unlockMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected