ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
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();
})
.subscribe_on(rpp::schedulers::new_thread{})
.as_blocking()
.subscribe([](int v) { std::cout << "[" << std::this_thread::get_id() << "] : " << v << "\n"; });
// Template for output:
// TH1
// on_subscribe thread TH2
// [TH2]: 1
return 0;
}
scheduler which schedules execution of schedulables via queueing tasks to another thread with priorit...
Definition: new_thread_scheduler.hpp:32