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++.
Namespaces | Macros | Functions
rx-range.hpp File Reference

Returns an observable that sends values in the range first-last by adding step to the previous value. The values are sent on the specified scheduler. More...

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

Go to the source code of this file.

Namespaces

 rxcpp
 
 rxcpp::sources
 

Macros

#define RXCPP_SOURCES_RX_RANGE_HPP
 

Functions

template<class T >
auto rxcpp::sources::range (T first=0, T last=std::numeric_limits< T >::max(), std::ptrdiff_t step=1) -> observable< T, detail::range< T, identity_one_worker >>
 Returns an observable that executes the specified function when a subscriber subscribes to it. More...
 
template<class T , class Coordination >
auto rxcpp::sources::range (T first, T last, std::ptrdiff_t step, Coordination cn) -> observable< T, detail::range< T, Coordination >>
 Returns an observable that executes the specified function when a subscriber subscribes to it. More...
 
template<class T , class Coordination >
auto rxcpp::sources::range (T first, T last, Coordination cn) -> typename std::enable_if< is_coordination< Coordination >::value, observable< T, detail::range< T, Coordination >>>::type
 Returns an observable that executes the specified function when a subscriber subscribes to it. More...
 
template<class T , class Coordination >
auto rxcpp::sources::range (T first, Coordination cn) -> typename std::enable_if< is_coordination< Coordination >::value, observable< T, detail::range< T, Coordination >>>::type
 Returns an observable that executes the specified function when a subscriber subscribes to it. More...
 

Detailed Description

Returns an observable that sends values in the range first-last by adding step to the previous value. The values are sent on the specified scheduler.

Template Parameters
Tthe type of the values that this observable emits
Coordinationthe type of the scheduler (optional)
Parameters
firstfirst value to send (optional)
lastlast value to send (optional)
stepvalue to add to the previous value to get the next value (optional)
cnthe scheduler to run the generator loop on (optional)
Returns
Observable that sends values in the range first-last by adding step to the previous value using the specified scheduler.
Sample Code
printf("[thread %s] Start task\n", get_pid().c_str());
auto s = values.
map([](int v) { return std::make_tuple(get_pid(), v);});
s.
[](const std::string pid, int v) {
printf("[thread %s] OnNext: %d\n", pid.c_str(), v);
}),
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 47481267428736] Start task
[thread 47481303181056] OnNext: 1
[thread 47481303181056] OnNext: 2
[thread 47481303181056] OnNext: 3
[thread 47481303181056] OnCompleted
[thread 47481267428736] Finish task
An alternative way to specify the scheduler for emitted values is to use observable::subscribe_on operator
printf("[thread %s] Start task\n", get_pid().c_str());
auto values = rxcpp::observable<>::range(1, 3);
auto s = values.
map([](int v) { return std::make_tuple(get_pid(), v);});
s.
[](const std::string pid, int v) {
printf("[thread %s] OnNext: %d\n", pid.c_str(), v);
}),
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 47481267428736] Start task
[thread 47481303181056] OnNext: 1
[thread 47481303181056] OnNext: 2
[thread 47481303181056] OnNext: 3
[thread 47481303181056] OnCompleted
[thread 47481267428736] Finish task

Macro Definition Documentation

#define RXCPP_SOURCES_RX_RANGE_HPP