13#include <rpp/schedulers/fwd.hpp>
15#include <rpp/defs.hpp>
16#include <rpp/disposables/disposable_wrapper.hpp>
17#include <rpp/utils/constraints.hpp>
19namespace rpp::schedulers
21 template<rpp::schedulers::constra
int::strategy Strategy>
25 template<
typename... Args>
27 explicit worker(Args&&... args)
28 : m_strategy(std::forward<Args>(args)...)
32 worker(
const worker&) =
default;
33 worker(worker&&) noexcept = default;
35 template<rpp::schedulers::constraint::schedulable_handler Handler, typename... Args, constraint::schedulable_fn<Handler, Args...> Fn>
36 void schedule(Fn&& fn, Handler&& handler, Args&&... args)
const
38 schedule(duration{}, std::forward<Fn>(fn), std::forward<Handler>(handler), std::forward<Args>(args)...);
42 void schedule(
const duration delay, Fn&& fn, Handler&& handler, Args&&... args)
const
44 if constexpr (constraint::defer_for_strategy<Strategy>)
45 m_strategy.defer_for(delay, std::forward<Fn>(fn), std::forward<Handler>(handler), std::forward<Args>(args)...);
47 schedule(now() + delay, std::forward<Fn>(fn), std::forward<Handler>(handler), std::forward<Args>(args)...);
51 void schedule(
const time_point tp, Fn&& fn, Handler&& handler, Args&&... args)
const
53 if constexpr (constraint::defer_to_strategy<Strategy>)
54 m_strategy.defer_to(tp, std::forward<Fn>(fn), std::forward<Handler>(handler), std::forward<Args>(args)...);
56 schedule(tp - now(), std::forward<Fn>(fn), std::forward<Handler>(handler), std::forward<Args>(args)...);
59 static rpp::schedulers::time_point now() {
return Strategy::now(); }
62 RPP_NO_UNIQUE_ADDRESS Strategy m_strategy;
Definition constraints.hpp:43
Definition constraints.hpp:31