RxCpp
The Reactive Extensions for Native (RxCpp) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in both C and C++.
Classes | Namespaces | Macros | Functions
rx-observe_on.hpp File Reference

All values are queued and delivered using the scheduler from the supplied coordination. More...

#include "../rx-includes.hpp"
Include dependency graph for rx-observe_on.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rxcpp::member_overload< observe_on_tag >
 
class  rxcpp::observe_on_one_worker
 

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_OBSERVE_ON_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::observe_on (AN &&... an) -> operator_factory< observe_on_tag, AN... >
 
observe_on_one_worker rxcpp::observe_on_run_loop (const rxsc::run_loop &rl)
 
observe_on_one_worker rxcpp::observe_on_event_loop ()
 
observe_on_one_worker rxcpp::observe_on_new_thread ()
 

Detailed Description

All values are queued and delivered using the scheduler from the supplied coordination.

Template Parameters
Coordinationthe type of the scheduler.
Parameters
cnthe scheduler to notify observers on.
Returns
The source observable modified so that its observers are notified on the specified scheduler.
Sample Code\n
printf("[thread %s] Start task\n", get_pid().c_str());
auto values = rxcpp::observable<>::range(1, 3).
map([](int v){
printf("[thread %s] Emit value %d\n", get_pid().c_str(), v);
return v;
});
values.
[](int v){printf("[thread %s] OnNext: %d\n", get_pid().c_str(), v);},
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 3070107664] Start task
[thread 3070107664] Emit value 1
[thread 3070107664] Emit value 2
[thread 3070107664] Emit value 3
[thread 3015701568] OnNext: 1
[thread 3015701568] OnNext: 2
[thread 3015701568] OnNext: 3
[thread 3015701568] OnCompleted
[thread 3070107664] Finish task
Invoking rxcpp::observable::subscribe_on operator, instead of observe_on, gives following results:
[thread 3070107664] Start task
[thread 2967462976] Emit value 1
[thread 2967462976] OnNext: 1
[thread 2967462976] Emit value 2
[thread 2967462976] OnNext: 2
[thread 2967462976] Emit value 3
[thread 2967462976] OnNext: 3
[thread 2967462976] OnCompleted
[thread 3070107664] Finish task

Macro Definition Documentation

◆ RXCPP_OPERATORS_RX_OBSERVE_ON_HPP

#define RXCPP_OPERATORS_RX_OBSERVE_ON_HPP
rxcpp::operators::map
auto map(AN &&... an) -> operator_factory< map_tag, AN... >
Definition: rx-map.hpp:105
rxcpp::operators::observe_on
auto observe_on(AN &&... an) -> operator_factory< observe_on_tag, AN... >
Definition: rx-observe_on.hpp:232
rxcpp::sources::range
auto range(T first=0, T last=std::numeric_limits< T >::max(), std::ptrdiff_t step=1) -> observable< T, detail::range< T, identity_one_worker >>
Definition: rx-range.hpp:119
rxcpp::operators::as_blocking
auto as_blocking() -> detail::blocking_factory
Definition: rx-subscribe.hpp:144
rxcpp::operators::subscribe
auto subscribe(ArgN &&... an) -> detail::subscribe_factory< decltype(make_subscriber< T >(std::forward< ArgN >(an)...))>
Definition: rx-subscribe.hpp:87
rxcpp::synchronize_new_thread
synchronize_in_one_worker synchronize_new_thread()
Definition: rx-synchronize.hpp:255