MCPcopy Create free account
hub / github.com/LiteLDev/LeviLamina / Impl

Method Impl

src/ll/api/thread/ThreadPoolExecutor.cpp:78–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76 return *scheduledWorker;
77 }
78 Impl(Executor& self, size_t nThreads) {
79 for (size_t i = 0; i < nThreads; ++i) {
80 workers.emplace_back([this, &self, i] {
81 setThreadName(fmt::format("{}[{}]", self.getName(), i));
82 decltype(tasks)::consumer_token_t token{tasks};
83 for (;;) {
84 std::function<void()> task;
85 taskCount.acquire();
86 while (!tasks.try_dequeue(token, task)) {
87 if (stop.load(std::memory_order_relaxed)) {
88 return;
89 }
90 }
91 try {
92 task();
93 } catch (...) {
94 getLogger().error("Error in {}[{}]:", self.getName(), i);
95 error_utils::printCurrentException(getLogger());
96 }
97 }
98 });
99 }
100 }
101 ~Impl() {
102 stop = true;
103 taskCount.release(workers.size());

Callers

nothing calls this directly

Calls 5

setThreadNameFunction · 0.85
printCurrentExceptionFunction · 0.85
getNameMethod · 0.45
loadMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected