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

Return an observable that emits observables every period time interval and collects items from this observable for period of time into each produced observable, on the specified scheduler. If the skip parameter is set, return an observable that emits observables every skip time interval and collects items from this observable for period of time into each produced observable, on the specified scheduler. More...

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

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_WINDOW_WITH_TIME_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::window_with_time (AN &&...an) -> operator_factory< window_with_time_tag, AN... >
 Return an observable that emits observables every period time interval and collects items from this observable for period of time into each produced observable, on the specified scheduler. If the skip parameter is set, return an observable that emits observables every skip time interval and collects items from this observable for period of time into each produced observable, on the specified scheduler. More...
 

Detailed Description

Return an observable that emits observables every period time interval and collects items from this observable for period of time into each produced observable, on the specified scheduler. If the skip parameter is set, return an observable that emits observables every skip time interval and collects items from this observable for period of time into each produced observable, on the specified scheduler.

Template Parameters
Durationthe type of time intervals.
Coordinationthe type of the scheduler (optional).
Parameters
periodthe period of time each window collects items before it is completed.
skipthe period of time after which a new window will be created.
coordinationthe scheduler for the windows (optional).
Returns
Observable that emits observables every period time interval and collect items from this observable for period of time into each produced observable. If the skip parameter is set, return an Observable that emits observables every skip time interval and collect items from this observable for period of time into each produced observable.
Sample Code
int counter = 0;
auto period = std::chrono::milliseconds(4);
auto skip = std::chrono::milliseconds(6);
auto values = rxcpp::observable<>::interval(std::chrono::steady_clock::now() + std::chrono::milliseconds(1), std::chrono::milliseconds(2)).
take(7).
values.
[&counter](rxcpp::observable<long> v){
int id = counter++;
printf("[window %d] Create window\n", id);
[id](long v){printf("[window %d] OnNext: %ld\n", id, v);},
[id](){printf("[window %d] OnCompleted\n", id);});
});
[window 0] Create window
[window 0] OnNext: 1
[window 0] OnNext: 2
[window 0] OnCompleted
[window 1] Create window
[window 1] OnNext: 4
[window 1] OnNext: 5
[window 1] OnCompleted
[window 2] Create window
[window 2] OnNext: 7
[window 2] OnCompleted
Sample Code
int counter = 0;
auto period = std::chrono::milliseconds(4);
auto skip = std::chrono::milliseconds(6);
auto values = rxcpp::observable<>::interval(std::chrono::steady_clock::now() + std::chrono::milliseconds(1), std::chrono::milliseconds(2)).
take(7).
values.
[&counter](rxcpp::observable<long> v){
int id = counter++;
printf("[window %d] Create window\n", id);
[id](long v){printf("[window %d] OnNext: %ld\n", id, v);},
[id](){printf("[window %d] OnCompleted\n", id);});
});
[window 0] Create window
[window 0] OnNext: 1
[window 0] OnNext: 2
[window 0] OnCompleted
[window 1] Create window
[window 1] OnNext: 4
[window 1] OnNext: 5
[window 1] OnCompleted
[window 2] Create window
[window 2] OnNext: 7
[window 2] OnCompleted
Sample Code
int counter = 0;
auto values = rxcpp::observable<>::interval(std::chrono::steady_clock::now() + std::chrono::milliseconds(1), std::chrono::milliseconds(2)).
take(7).
window_with_time(std::chrono::milliseconds(4), rxcpp::observe_on_new_thread());
values.
[&counter](rxcpp::observable<long> v){
int id = counter++;
printf("[window %d] Create window\n", id);
[id](long v){printf("[window %d] OnNext: %ld\n", id, v);},
[id](){printf("[window %d] OnCompleted\n", id);});
});
[window 0] Create window
[window 0] OnNext: 1
[window 0] OnNext: 2
[window 1] Create window
[window 0] OnCompleted
[window 1] OnNext: 3
[window 1] OnNext: 4
[window 2] Create window
[window 1] OnCompleted
[window 2] OnNext: 5
[window 2] OnNext: 6
[window 3] Create window
[window 2] OnCompleted
[window 3] OnNext: 7
[window 3] OnCompleted
Sample Code
int counter = 0;
auto values = rxcpp::observable<>::interval(std::chrono::steady_clock::now() + std::chrono::milliseconds(1), std::chrono::milliseconds(2)).
take(7).
window_with_time(std::chrono::milliseconds(4));
values.
[&counter](rxcpp::observable<long> v){
int id = counter++;
printf("[window %d] Create window\n", id);
[id](long v){printf("[window %d] OnNext: %ld\n", id, v);},
[id](){printf("[window %d] OnCompleted\n", id);});
});
[window 0] Create window
[window 0] OnNext: 1
[window 0] OnNext: 2
[window 1] Create window
[window 0] OnCompleted
[window 1] OnNext: 3
[window 1] OnNext: 4
[window 2] Create window
[window 1] OnCompleted
[window 2] OnNext: 5
[window 2] OnNext: 6
[window 3] Create window
[window 2] OnCompleted
[window 3] OnNext: 7
[window 3] OnCompleted

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_WINDOW_WITH_TIME_HPP