Skip to Content
C++ Reactive Programming
book

C++ Reactive Programming

by Praseed Pai, Peter Abraham
June 2018
Intermediate to advanced
348 pages
8h 45m
English
Packt Publishing
Content preview from C++ Reactive Programming

The RunLoop Scheduler

The RxCpp library does not have a notion of  built-in main thread Scheduler. The closest you can do is to leverage the run_loop class to simulate scheduling in the main thread. In the following program, the Observable executes in a background thread, and the subscription methods run in the main thread. We are using subscribe_on and observe_on to achieve this objective:

//------------- RunLoop.cpp #include "rxcpp/rx.hpp" int main(){ //------------ Print the Main Thread Id printf("Main Thread Id is %dn", std::this_thread::get_id()); //------- Instantiate a run_loop object //------- which will loop in the main thread rxcpp::schedulers::run_loop rlp; //------ Create a Coordination functionfor run loop auto main_thread = ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in C++

Functional Programming in C++

Ivan Cukic

Publisher Resources

ISBN: 9781788629775Supplemental Content