Return an observable that emits buffers every period time interval and collects items from this observable for period of time into each produced buffer. If the skip parameter is set, Return an observable that emits buffers every skip time interval and collects items from this observable for period of time into each produced buffer, on the specified scheduler.
More...
Go to the source code of this file.
|
template<class... AN> |
auto | rxcpp::operators::buffer_with_time (AN &&... an) -> operator_factory< buffer_with_time_tag, AN... > |
| Return an observable that emits buffers every period time interval and collects items from this observable for period of time into each produced buffer. If the skip parameter is set, Return an observable that emits buffers every skip time interval and collects items from this observable for period of time into each produced buffer, on the specified scheduler. More...
|
|
Return an observable that emits buffers every period time interval and collects items from this observable for period of time into each produced buffer. If the skip parameter is set, Return an observable that emits buffers every skip time interval and collects items from this observable for period of time into each produced buffer, on the specified scheduler.
- Template Parameters
-
Duration | the type of the time interval |
Coordination | the type of the scheduler (optional). |
- Parameters
-
period | the period of time each buffer collects items before it is emitted. |
skip | the period of time after which a new buffer will be created (optional). |
coordination | the scheduler for the buffers (optional). |
- Returns
- Observable that emits buffers every period time interval and collect items from this observable for period of time into each produced buffer. If the skip parameter is set, return an Observable that emits buffers every skip time interval and collect items from this observable for period of time into each produced buffer.
- Sample Code\n
printf("[thread %s] Start task\n", get_pid().c_str());
auto period = std::chrono::milliseconds(4);
auto skip = std::chrono::milliseconds(6);
printf("[thread %s] Interval OnNext: %ld\n", get_pid().c_str(), v);
return v;
}).
values.
[](std::vector<long> v){
printf("[thread %s] OnNext:", get_pid().c_str());
std::for_each(v.begin(), v.end(), [](long a){
printf(" %ld", a);
});
printf("\n");
},
[](){printf("[thread %s] OnCompleted\n", get_pid().c_str());});
printf("[thread %s] Finish task\n", get_pid().c_str());
[thread 139846724265792] Start task
[thread 139846724265792] Interval OnNext: 1
[thread 139846724265792] Interval OnNext: 2
[thread 139846724261632] OnNext: 1 2
[thread 139846724265792] Interval OnNext: 3
[thread 139846724265792] Interval OnNext: 4
[thread 139846724265792] Interval OnNext: 5
[thread 139846724261632] OnNext: 4 5
[thread 139846724265792] Interval OnNext: 6
[thread 139846724265792] Interval OnNext: 7
[thread 139846724261632] OnNext: 7
[thread 139846724261632] OnCompleted
[thread 139846724265792] Finish task
- Sample Code\n
auto period = std::chrono::milliseconds(4);
auto skip = std::chrono::milliseconds(6);
values.
[](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: 4 5
OnNext: 7
OnCompleted
Overlapping buffers are allowed: auto period = std::chrono::milliseconds(6);
auto skip = std::chrono::milliseconds(4);
values.
[](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 3
OnNext: 3 4 5
OnNext: 5 6 7
OnNext: 7
OnCompleted
If no items are emitted, an empty buffer is returned: auto period = std::chrono::milliseconds(2);
auto skip = std::chrono::milliseconds(4);
values.
[](std::vector<long> v){
printf("OnNext:");
std::for_each(v.begin(), v.end(), [](long a){
printf(" %ld", a);
});
printf("\n");
},
[](){printf("OnCompleted\n");});
OnNext:
OnNext:
OnNext: 1
OnCompleted
- Sample Code\n
values.
[](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 4
OnNext: 5 6
OnNext: 7
OnCompleted
- Sample Code\n
values.
[](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 4
OnNext: 5 6
OnNext: 7
OnCompleted
◆ RXCPP_OPERATORS_RX_BUFFER_WITH_TIME_HPP
#define RXCPP_OPERATORS_RX_BUFFER_WITH_TIME_HPP |