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

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

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

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_BUFFER_WITH_TIME_OR_COUNT_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::buffer_with_time_or_count (AN &&...an) -> operator_factory< buffer_with_time_or_count_tag, AN... >
 Return an observable that emits connected, non-overlapping buffers of items from the source observable that were emitted during a fixed duration of time or when the buffer has reached maximum capacity (whichever occurs first), on the specified scheduler. More...
 

Detailed Description

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

Template Parameters
Durationthe type of the time interval.
Coordinationthe type of the scheduler (optional).
Parameters
periodthe period of time each buffer collects items before it is emitted and replaced with a new buffer.
countthe maximum size of each buffer before it is emitted and new buffer is created.
coordinationthe scheduler for the buffers (optional).
Returns
Observable that emits connected, non-overlapping buffers of items from the source observable that were emitted during a fixed duration of time or when the buffer has reached maximum capacity (whichever occurs first).
Sample Code
auto start = std::chrono::steady_clock::now();
auto int1 = rxcpp::observable<>::range(1L, 3L);
auto int2 = rxcpp::observable<>::timer(std::chrono::milliseconds(50));
auto values = int1.
concat(int2).
buffer_with_time_or_count(std::chrono::milliseconds(20), 2, rxcpp::observe_on_event_loop());
values.
[start](std::vector<long> v){
printf("OnNext:");
std::for_each(v.begin(), v.end(), [](long a){
printf(" %ld", a);
});
printf("\n");
},
[](){printf("OnCompleted\n");});
OnNext: 1 2
OnNext: 3
OnNext:
OnNext: 1
OnCompleted
Sample Code
auto start = std::chrono::steady_clock::now();
auto int1 = rxcpp::observable<>::range(1L, 3L);
auto int2 = rxcpp::observable<>::timer(std::chrono::milliseconds(50));
auto values = int1.
concat(int2).
buffer_with_time_or_count(std::chrono::milliseconds(20), 2);
values.
[start](std::vector<long> v){
printf("OnNext:");
std::for_each(v.begin(), v.end(), [](long a){
printf(" %ld", a);
});
printf("\n");
},
[](){printf("OnCompleted\n");});
OnNext: 1 2
OnNext: 3
OnNext:
OnNext: 1
OnCompleted

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_BUFFER_WITH_TIME_OR_COUNT_HPP