ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
rpp::schedulers::trampoline Class Referencefinal

Schedules execution of schedulables via queueing tasks to the caller thread with priority to time_point and order. More...

#include <trampoline_scheduler.hpp>

Inheritance diagram for rpp::schedulers::trampoline:
rpp::schedulers::details::scheduler_tag

Static Public Member Functions

static utils::finally_action< void(*)()> own_queue_and_drain_finally_if_not_owned ()
 
static auto create_worker (const rpp::composite_subscription &sub=composite_subscription{})
 

Detailed Description

Schedules execution of schedulables via queueing tasks to the caller thread with priority to time_point and order.

Warning
Caller thread is thread where "schedule" called.
For example, in case of merging values from two threads/observables and then using "trampoline", then it would be thread_local for each emission/thread, not one thread selected for all threads.
Example
rpp::source::just(rpp::schedulers::trampoline{}, 1, 2, 3)
.merge_with(rpp::source::just(rpp::schedulers::trampoline{}, 4, 5, 6))
.subscribe([](const int& v) { std::cout << "-" << v; },
[]() { std::cout << "-|" << std::endl; });
// Source 1: -1-2-3-|
// Source 2: -4-5-6-|
// Output : -1-4-2-5-3-6-|
// // TODO: Enable this when we have "combine_latest" operator
// rpp::source::just(rpp::schedulers::trampoline{}, 1, 2, 3)
// .with_latest_from(rpp::source::just(rpp::schedulers::trampoline{}, 4, 5, 6))
// .observe_on(rpp::schedulers::trampoline{})
// .subscribe(
// [](const auto &v) { std::cout << v << "-"; },
// [](const std::exception_ptr &error) {},
// []() { std::cout << "|" << std::endl; });
// // Source: -1-2-3--|
// // -1-2-3--|
// // Output: {1,1}-{2,2}-{3,3}-|
Schedules execution of schedulables via queueing tasks to the caller thread with priority to time_poi...
Definition: trampoline_scheduler.hpp:41
Examples
combine_latest.cpp, debounce.cpp, sample.cpp, take_until.cpp, and trampoline.cpp.

The documentation for this class was generated from the following file: