-
Notifications
You must be signed in to change notification settings - Fork 402
Description
Hi, I have few questions
-
Do I need to add scheduler to merge operator in this code? When do I have to provide it and why?
auto src1 = rxcpp::sources::interval(std::chrono::seconds(1), rxcpp::observe_on_new_thread())
.map([](auto i){
return "1# i: " + std::to_string(i);
});auto src2 = rxcpp::sources::interval(std::chrono::milliseconds(500), rxcpp::observe_on_new_thread())
.map([](auto i){
return "2# i: " + std::to_string(i);
});src1
.merge(src2)
.subscribe([](auto s){
std::cout << s << std::endl;
}); -
Can I do something like this if I want to have only one thread instead of two (or three in case if I have to create anothed one for merge operator)?
auto sc = rxcpp::schedulers::make_new_thread();
auto w = sc.create_worker();
auto so = rxcpp::identity_same_worker(w);auto src1 = rxcpp::sources::interval(std::chrono::seconds(1), so)
.map([](auto i){
return "1# i: " + std::to_string(i);
});auto src2 = rxcpp::sources::interval(std::chrono::milliseconds(500), so)
.map([](auto i){
return "2# i: " + std::to_string(i);
});src1
.merge(src2)
.subscribe([](auto s){
std::cout << s << std::endl;
});