9#ifndef STLAB_CONCURRENCY_EXECUTOR_BASE_HPP
10#define STLAB_CONCURRENCY_EXECUTOR_BASE_HPP
22#include <stlab/config.hpp>
33STLAB_VERSION_NAMESPACE_BEGIN()
47template <typename Rep, typename Per = std::ratio<1>>
49 return [_duration = std::move(duration), _executor = std::move(
executor)](
auto f)
mutable {
50 if (_duration != std::chrono::duration<Rep, Per>{})
52 [_f = std::move(f), _executor = std::move(_executor)]()
mutable noexcept {
53 _executor(std::move(_f));
56 _executor(std::move(f));
61[[deprecated(
"Use chrono::duration as parameter instead")]]
inline auto execute_at(
63 using namespace std::chrono;
64 return execute_at(duration_cast<nanoseconds>(when - steady_clock::now()), std::move(
executor));
68template <
typename E,
typename Rep,
typename Per = std::ratio<1>>
99STLAB_VERSION_NAMESPACE_END()
std::function< void(stlab::task< void() noexcept >)> executor_t
Type-erased executor: accepts a void() noexcept task.
Definition executor_base.hpp:44
auto execute_delayed(std::chrono::duration< Rep, Per > duration, E executor)
Returns an executor that delays each submitted task by duration before forwarding to executor.
Definition executor_base.hpp:69
auto execute_at(std::chrono::duration< Rep, Per > duration, executor_t executor) -> executor_t
Returns an executor that posts tasks to executor after duration (immediate if zero).
Definition executor_base.hpp:48
constexpr auto system_timer
Schedules void() noexcept tasks on a system timer / run loop (platform-dependent).
Definition system_timer.hpp:341
typename noexcept_deducer< task_, F >::type task
task_ with noexcept deduced from the function type F (e.g. void() vs void() noexcept).
Definition task.hpp:324
Definition reverse.hpp:28
Executor plus callable, produced by executor & f (used by futures and channels).
Definition executor_base.hpp:80
Wraps an executor_t for use with operator&.
Definition executor_base.hpp:74
System timer / delayed execution (platform run loop or portable thread).
Move-only callable wrapper for executor scheduling (task<Signature>).