13#include <rpp/disposables/fwd.hpp>
15#include <rpp/utils/constraints.hpp>
20namespace rpp::schedulers
22 using clock_type = std::chrono::steady_clock;
23 using time_point = clock_type::time_point;
24 using duration = std::chrono::nanoseconds;
71 explicit delay_to(time_point timepoint = {})
79 using optional_delay_from_now = std::optional<delay_from_now>;
80 using optional_delay_from_this_timepoint = std::optional<delay_from_this_timepoint>;
81 using optional_delay_to = std::optional<delay_to>;
84namespace rpp::schedulers::details
88 constexpr static bool is_disposed() {
return true; }
90 static void on_error(
const std::exception_ptr&) {}
94namespace rpp::schedulers::constraint
97 template<
typename Fn,
typename... Args>
98 concept schedulable_delay_from_now_fn = std::is_invocable_r_v<optional_delay_from_now, Fn, Args&...> && std::same_as<std::invoke_result_t<Fn, Args&...>, optional_delay_from_now>;
101 template<
typename Fn,
typename... Args>
102 concept schedulable_delay_from_this_timepoint_fn = std::is_invocable_r_v<optional_delay_from_this_timepoint, Fn, Args&...> && std::same_as<std::invoke_result_t<Fn, Args&...>, optional_delay_from_this_timepoint>;
105 template<
typename Fn,
typename... Args>
106 concept schedulable_delay_to_fn = std::is_invocable_r_v<optional_delay_to, Fn, Args&...> && std::same_as<std::invoke_result_t<Fn, Args&...>, optional_delay_to>;
109 template<
typename Fn,
typename... Args>
112 template<
typename Handler>
115 handler.is_disposed()
116 } -> std::same_as<bool>;
117 handler.on_error(std::exception_ptr{});
121 concept defer_for_strategy =
requires(
const S& s,
const details::fake_schedulable_handler& handler) {
123 s.defer_for(duration{}, std::declval<optional_delay_from_now (*)(const details::fake_schedulable_handler&)>(), handler)
124 } -> std::same_as<void>;
126 s.defer_for(duration{}, std::declval<optional_delay_from_this_timepoint (*)(const details::fake_schedulable_handler&)>(), handler)
127 } -> std::same_as<void>;
129 s.defer_for(duration{}, std::declval<optional_delay_to (*)(const details::fake_schedulable_handler&)>(), handler)
130 } -> std::same_as<void>;
134 concept defer_to_strategy =
requires(
const S& s,
const details::fake_schedulable_handler& handler) {
136 s.defer_to(time_point{}, std::declval<optional_delay_from_now (*)(const details::fake_schedulable_handler&)>(), handler)
137 } -> std::same_as<void>;
139 s.defer_to(time_point{}, std::declval<optional_delay_from_this_timepoint (*)(const details::fake_schedulable_handler&)>(), handler)
140 } -> std::same_as<void>;
142 s.defer_to(time_point{}, std::declval<optional_delay_to (*)(const details::fake_schedulable_handler&)>(), handler)
143 } -> std::same_as<void>;
150 } -> std::same_as<rpp::schedulers::time_point>;
154namespace rpp::schedulers
156 template<rpp::schedulers::constra
int::strategy Strategy>
172namespace rpp::schedulers::constraint
181 template<constra
int::strategy Strategy>
188 concept worker = details::is_worker<W>::value;
198namespace rpp::schedulers::utils
200 template<rpp::schedulers::constra
int::scheduler Scheduler>
201 using get_worker_t = std::decay_t<decltype(std::declval<Scheduler>().create_worker())>;
Scheduler owning static thread pool of workers and using "some" thread from this pool on create_worke...
Definition computational.hpp:30
Schedules execution of schedulables via queueing tasks to the caller thread with priority to time_poi...
Definition current_thread.hpp:86
Scheduler which schedules invoking of schedulables to another thread via queueing tasks with priority...
Definition new_thread.hpp:31
scheduler which schedules execution via queueing tasks, but execution of tasks should be manually dis...
Definition run_loop.hpp:31
Scheduler owning static thread pool of workers and using "some" thread from this pool on create_worke...
Definition thread_pool.hpp:31
Timepoint of next execution would be calculcated from NOW timpoint (time of returning from schedulabl...
Definition fwd.hpp:36
Timepoint of next execution would be calculcated from timepoint of current scheduling.
Definition fwd.hpp:57
Provide timepoint of next execution explicitly.
Definition fwd.hpp:70