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

Method executeAfter

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

Source from the content-addressed store, hash-verified

121 impl->taskCount.release();
122}
123std::shared_ptr<data::CancellableCallback>
124ThreadPoolExecutor::executeAfter(std::function<void()> f, Duration dur) const {
125 if (dur <= Duration{0}) {
126 execute(std::move(f));
127 return nullptr;
128 } else {
129 auto& worker = impl->getScheduledWorker(*this);
130 auto res = std::make_shared<data::CancellableCallback>(std::move(f));
131 worker.works.emplace(Clock::now() + dur, res);
132 worker.sleeper.interrupt();
133 return res;
134 }
135}
136ThreadPoolExecutor const& ThreadPoolExecutor::getDefault() {
137 static ThreadPoolExecutor ins("ll_default_thread_pool", std::max((int)std::thread::hardware_concurrency() - 2, 2));
138 return ins;

Callers

nothing calls this directly

Calls 2

emplaceMethod · 0.45
interruptMethod · 0.45

Tested by

no test coverage detected