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

Returns an observable that attaches a timestamp to each item emitted by the source observable indicating when it was emitted. More...

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

Namespaces

 rxcpp
 
 rxcpp::operators
 

Macros

#define RXCPP_OPERATORS_RX_TIMESTAMP_HPP
 

Functions

template<class... AN>
auto rxcpp::operators::timestamp (AN &&...an) -> operator_factory< timestamp_tag, AN... >
 Returns an observable that attaches a timestamp to each item emitted by the source observable indicating when it was emitted. More...
 

Detailed Description

Returns an observable that attaches a timestamp to each item emitted by the source observable indicating when it was emitted.

Template Parameters
Coordinationthe type of the scheduler (optional).
Parameters
coordinationthe scheduler to manage timeout for each event (optional).
Returns
Observable that emits a pair: { item emitted by the source observable, time_point representing the current value of the clock }.
Sample Code
typedef rxcpp::schedulers::scheduler::clock_type::time_point time_point;
using namespace std::chrono;
auto values = rxcpp::observable<>::interval(milliseconds(100))
.timestamp()
.take(3);
time_point start = rxcpp::identity_current_thread().now();
values.
[&](std::pair<long, time_point> v) {
long long int ms = duration_cast<milliseconds>(v.second - start).count();
printf("OnNext: %ld @%lldms\n", v.first, ms);
},
[](std::exception_ptr ep) {
try {
std::rethrow_exception(ep);
} catch (const std::exception& ex) {
printf("OnError: %s\n", ex.what());
}
},
[]() { printf("OnCompleted\n"); });
OnNext: 1 @0ms
OnNext: 2 @100ms
OnNext: 3 @200ms
OnCompleted

Macro Definition Documentation

#define RXCPP_OPERATORS_RX_TIMESTAMP_HPP