ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
immediate_scheduler.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2022 - present.
4// Distributed under the Boost Software License, Version 1.0.
5// (See accompanying file LICENSE_1_0.txt or copy at
6// https://www.boost.org/LICENSE_1_0.txt)
7//
8// Project home: https://github.com/victimsnino/ReactivePlusPlus
9//
10
11#pragma once
12
13#include <rpp/schedulers/fwd.hpp> // own forwarding
14#include <rpp/schedulers/details/worker.hpp> // worker
15#include <rpp/subscriptions/subscription_base.hpp> // lifetime
16#include <rpp/schedulers/details/utils.hpp>
17
18#include <chrono>
19#include <concepts>
20
21namespace rpp::schedulers
22{
28{
29public:
31 {
32 public:
34 : m_sub{sub} {}
35
36 void defer_at(time_point time_point, constraint::schedulable_fn auto&& fn) const
37 {
38 details::immediate_scheduling_while_condition(time_point, std::forward<decltype(fn)>(fn), m_sub, []{return true;});
39 }
40
41 static time_point now() { return clock_type::now(); }
42 private:
44 };
45
46 static auto create_worker(const rpp::subscription_base& sub = {})
47 {
48 return worker<worker_strategy>{sub};
49 }
50};
51} // namespace rpp::schedulers
immediately calls provided schedulable or waits for time_point (in the caller-thread)
Definition: immediate_scheduler.hpp:28
Definition: worker.hpp:60
Base subscription implementation used as base class/interface and core implementation for derrived su...
Definition: subscription_base.hpp:25
Definition: constraints.hpp:22
Definition: worker.hpp:23