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