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

Method executeAfter

src/ll/api/thread/ServerThreadExecutor.cpp:93–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91void ServerThreadExecutor::execute(std::function<void()> f) const { impl->shared->works.enqueue(std::move(f)); }
92
93std::shared_ptr<data::CancellableCallback>
94ServerThreadExecutor::executeAfter(std::function<void()> f, Duration dur) const {
95 auto tick = std::chrono::ceil<chrono::ticks>(dur).count();
96 if (tick <= 0) {
97 execute(std::move(f));
98 return nullptr;
99 } else {
100 auto res = std::make_shared<data::CancellableCallback>(std::move(f));
101 impl->shared->scheduledWorks.emplace(impl->shared->frame.load() + tick, res);
102 return res;
103 }
104}
105
106ServerThreadExecutor const& ServerThreadExecutor::getDefault() {
107 static ServerThreadExecutor ins("ll_default_server_thread", std::chrono::milliseconds{30}, 16);

Callers

nothing calls this directly

Calls 3

countMethod · 0.45
emplaceMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected