ReactivePlusPlus
ReactiveX implementation for C++20
Toggle main menu visibility
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_on
(
rpp::schedulers::new_thread
{})
|
rpp::operators::as_blocking
()
|
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;
}
rpp::schedulers::new_thread
Scheduler which schedules invoking of schedulables to another thread via queueing tasks with priority...
Definition
new_thread.hpp:31
rpp::source::create
auto create(OnSubscribe &&on_subscribe)
Construct observable specialized with passed callback function. Most easiesest way to construct obser...
Definition
create.hpp:57
rpp::operators::subscribe
auto subscribe(observer< Type, ObserverStrategy > &&observer)
Subscribes passed observer to emissions from this observable.
Definition
subscribe.hpp:226
rpp::operators::as_blocking
auto as_blocking()
Converts rpp::observable to rpp::blocking_observable.
Definition
as_blocking.hpp:47
rpp::operators::subscribe_on
auto subscribe_on(Scheduler &&scheduler)
OnSubscribe function for this observable will be scheduled via provided scheduler.
Definition
subscribe_on.hpp:75
Generated by
1.17.0