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

Return an observable that emits connected, non-overlapping windows of items from the source observable that were emitted during a fixed duration of time or when the window has reached maximum capacity (whichever occurs first), on the specified scheduler. More...

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

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_WINDOW_WITH_TIME_OR_COUNT_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::window_with_time_or_count (AN &&... an) -> operator_factory< window_with_time_or_count_tag, AN... >
 

Detailed Description

Return an observable that emits connected, non-overlapping windows of items from the source observable that were emitted during a fixed duration of time or when the window has reached maximum capacity (whichever occurs first), 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 and replaced with a new window.
countthe maximum size of each window before it is completed and new window is created.
coordinationthe scheduler for the windows (optional).
Returns
Observable that emits connected, non-overlapping windows of items from the source observable that were emitted during a fixed duration of time or when the window has reached maximum capacity (whichever occurs first).
Sample Code\n
int counter = 0;
auto int1 = rxcpp::observable<>::range(1L, 3L);
auto int2 = rxcpp::observable<>::timer(std::chrono::milliseconds(50));
auto values = int1.
concat(int2).
window_with_time_or_count(std::chrono::milliseconds(20), 2, rxcpp::observe_on_event_loop());
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: 3
[window 1] OnCompleted
[window 2] Create window
[window 2] OnCompleted
[window 3] Create window
[window 3] OnNext: 1
[window 3] OnCompleted
Sample Code\n
int counter = 0;
auto int1 = rxcpp::observable<>::range(1L, 3L);
auto int2 = rxcpp::observable<>::timer(std::chrono::milliseconds(50));
auto values = int1.
concat(int2).
window_with_time_or_count(std::chrono::milliseconds(20), 2);
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: 3
[window 1] OnCompleted
[window 2] Create window
[window 2] OnCompleted
[window 3] Create window
[window 3] OnNext: 1
[window 3] OnCompleted

Macro Definition Documentation

◆ RXCPP_OPERATORS_RX_WINDOW_WITH_TIME_OR_COUNT_HPP

#define RXCPP_OPERATORS_RX_WINDOW_WITH_TIME_OR_COUNT_HPP
rxcpp::operators::concat
auto concat(AN &&... an) -> operator_factory< concat_tag, AN... >
Definition: rx-concat.hpp:235
rxcpp::operators::window_with_time_or_count
auto window_with_time_or_count(AN &&... an) -> operator_factory< window_with_time_or_count_tag, AN... >
Definition: rx-window_time_count.hpp:236
rxcpp::sources::timer
auto timer(TimePointOrDuration when) -> typename std::enable_if< detail::defer_timer< TimePointOrDuration, identity_one_worker >::value, typename detail::defer_timer< TimePointOrDuration, identity_one_worker >::observable_type >::type
Definition: rx-timer.hpp:114
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::window
auto window(AN &&... an) -> operator_factory< window_tag, AN... >
Definition: rx-window.hpp:138
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::observable::subscribe
auto subscribe(ArgN &&... an) const -> composite_subscription
Definition: rx-observable.hpp:637
rxcpp::observe_on_event_loop
observe_on_one_worker observe_on_event_loop()
Definition: rx-observe_on.hpp:323
rxcpp::observable
a source of values. subscribe or use one of the operator methods that return a new observable,...
Definition: rx-observable.hpp:478