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

Writing a custom operator that involves Schedulers

The RxCpp library is single-threaded by default, and RxCpp will schedule execution in the thread where we called the subscriber method. There are some operators that take a Scheduler as a parameter, where execution can happen in the thread managed by the Scheduler. Let's write a program to implement a custom operator to work with a Scheduler parameter:

//----------- CustomOperatorScheduler.cpp #include "rxcpp/rx.hpp" template <typename Duration> auto generateObservable(Duration durarion) { //--------- start and the period auto start = rxcpp::identity_current_thread().now(); auto period = durarion; //--------- Observable upto 3 items return rxcpp::observable<>::interval(start, period).take(3); ...
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