ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
subscribe_on.cpp
#include <rpp/rpp.hpp>
#include <iostream>
int main()
{
std::cout << std::this_thread::get_id() << std::endl;
rpp::source::create<int>([](const auto& sub) {
std::cout << "on_subscribe thread " << std::this_thread::get_id() << std::endl;
sub.on_next(1);
sub.on_completed();
})
| rpp::operators::subscribe([](int v) { std::cout << "[" << std::this_thread::get_id() << "] : " << v << "\n"; });
std::cout << std::this_thread::get_id() << std::endl;
// Template for output:
// TH1
// on_subscribe thread TH2
// [TH2]: 1
// TH1
return 0;
}
Scheduler which schedules invoking of schedulables to another thread via queueing tasks with priority...
Definition new_thread.hpp:31
auto create(OnSubscribe &&on_subscribe)
Construct observable specialized with passed callback function. Most easiesest way to construct obser...
Definition create.hpp:57
auto subscribe(observer< Type, ObserverStrategy > &&observer)
Subscribes passed observer to emissions from this observable.
Definition subscribe.hpp:226
auto as_blocking()
Converts rpp::observable to rpp::blocking_observable
Definition as_blocking.hpp:47
auto subscribe_on(Scheduler &&scheduler)
OnSubscribe function for this observable will be scheduled via provided scheduler.
Definition subscribe_on.hpp:75