21 #include <glog/logging.h> 30 std::unique_lock<std::mutex>
lock(
m);
35 : threadFactory_(
std::
move(threadFactory)) {
40 stopping_.store(
true, std::memory_order_release);
48 CHECK(!
stopping_.load(std::memory_order_acquire));
54 return std::make_shared<NamedThreadFactory>(
"Threaded");
72 constexpr
auto kMaxWait = std::chrono::seconds(10);
80 auto id = std::this_thread::get_id();
86 std::deque<std::thread::id> finishedt;
88 for (
auto id : finishedt) {
95 std::deque<Func> enqueuedt;
97 for (
auto&
f : enqueuedt) {
100 auto id = th.get_id();
106 auto stopping =
stopping_.load(std::memory_order_acquire);
109 return !stopping || !
running_.empty();
std::deque< Func > enqueued_
std::condition_variable controlc_
void controlLaunchEnqueuedTasks()
static std::shared_ptr< ThreadFactory > newDefaultThreadFactory()
constexpr detail::Map< Move > move
static auto with_unique_lock(std::mutex &m, F &&f) -> decltype(f())
—— Concurrent Priority Queue Implementation ——
std::deque< std::thread::id > finished_
std::shared_ptr< ThreadFactory > threadFactory_
void add(Func func) override
~ThreadedExecutor() override
auto lock(Synchronized< D, M > &synchronized, Args &&...args)
static map< string, int > m
std::atomic< bool > stopping_
bool setThreadName(std::thread::id tid, StringPiece name)
std::map< std::thread::id, std::thread > running_
void controlJoinFinishedThreads()
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
ThreadedExecutor(std::shared_ptr< ThreadFactory > threadFactory=newDefaultThreadFactory())