LeviLamina
Loading...
Searching...
No Matches
Executor.h
1#pragma once
2
3#include <chrono>
4#include <functional>
5#include <memory>
6#include <string>
7#include <string_view>
8#include <type_traits>
9
10#include "ll/api/base/Macro.h"
11#include "ll/api/base/StdInt.h"
12#include "ll/api/data/CancellableCallback.h"
13
14#include "mc/deps/core/utility/optional_ref.h"
15
16namespace ll::coro {
17class Executor {
18 std::string name;
19
20public:
21 using Clock = std::chrono::steady_clock;
22 using Duration = Clock::duration;
23
24 Executor(std::string name) : name(std::move(name)) {}
25
26 std::string const& getName() const { return name; }
27
28 virtual ~Executor() = default;
29
30 virtual void execute(std::function<void()>) const = 0;
31
32 virtual std::shared_ptr<data::CancellableCallback> executeAfter(std::function<void()>, Duration) const = 0;
33};
34
36
37using NonNullExecutorRef = Executor const&;
38
39using Duration = Executor::Duration;
40
41constexpr inline struct CurrentExecutor {
42} currentExecutor;
43
44} // namespace ll::coro
Definition Executor.h:17
Definition optional_ref.h:10
Definition Executor.h:41