We already covered the topic of scheduling in Chapter 8, RxCpp – the Key Elements. The schedulers in RxCpp
queue up the values and deliver the queued up value using the supplied coordination. The coordination could be the current execution thread, the RxCpp
run loop, the RxCpp
event loop, or a new thread. The execution of scheduler operations can be achieved by using the RxCpp
Operators, such as observe_on()
or subscribe_on()
. These Operators accept the chosen coordination as an argument. By default, the RxCpp
library is single-threaded, so it does the scheduler operations. The user has to explicitly choose the thread in which execution happens:
//----------OnError_ObserveOn1.cpp #include "rxcpp/rx.hpp" #include <iostream> #include <thread> int main() { //---------------- Generate a range of values //---------------- Apply Square function auto values = rxcpp::observable<>::range(1, 4). transform([](int v) { return...