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-subscribe_on.hpp File Reference

Subscription and unsubscription are queued and delivered using the scheduler from the supplied coordination. More...

#include "../rx-includes.hpp"
Include dependency graph for rx-subscribe_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< subscribe_on_tag >
 

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_SUBSCRIBE_ON_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::subscribe_on (AN &&... an) -> operator_factory< subscribe_on_tag, AN... >
 Subscription and unsubscription are queued and delivered using the scheduler from the supplied coordination. More...
 

Detailed Description

Subscription and unsubscription are queued and delivered using the scheduler from the supplied coordination.

Template Parameters
Coordinationthe type of the scheduler.
Parameters
cnthe scheduler to perform subscription actions on.
Returns
The source observable modified so that its subscriptions happen on the specified scheduler.
Sample Code
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 139893954611008] Start task
[thread 139893309167360] Emit value 1
[thread 139893309167360] OnNext: 1
[thread 139893309167360] Emit value 2
[thread 139893309167360] OnNext: 2
[thread 139893309167360] Emit value 3
[thread 139893309167360] OnNext: 3
[thread 139893309167360] OnCompleted
[thread 139893954611008] Finish task
Invoking rxcpp::observable::observe_on operator, instead of subscribe_on, gives following results:
[thread 139893954611008] Start task
[thread 139893954611008] Emit value 1
[thread 139893954611008] Emit value 2
[thread 139893954611008] Emit value 3
[thread 139893829252864] OnNext: 1
[thread 139893829252864] OnNext: 2
[thread 139893829252864] OnNext: 3
[thread 139893829252864] OnCompleted
[thread 139893954611008] Finish task

Macro Definition Documentation

◆ RXCPP_OPERATORS_RX_SUBSCRIBE_ON_HPP

#define RXCPP_OPERATORS_RX_SUBSCRIBE_ON_HPP