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... >
 

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\n
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 {
} 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

◆ RXCPP_OPERATORS_RX_TIMESTAMP_HPP

#define RXCPP_OPERATORS_RX_TIMESTAMP_HPP
rxcpp::identity_one_worker::now
rxsc::scheduler::clock_type::time_point now() const
Definition: rx-coordination.hpp:160
rxcpp::identity_current_thread
identity_one_worker identity_current_thread()
Definition: rx-coordination.hpp:175
rxcpp::operators::subscribe
auto subscribe(ArgN &&... an) -> detail::subscribe_factory< decltype(make_subscriber< T >(std::forward< ArgN >(an)...))>
Definition: rx-subscribe.hpp:87
rxcpp::util::rethrow_exception
RXCPP_NORETURN void rethrow_exception(error_ptr e)
Definition: rx-util.hpp:902
rxcpp::sources::interval
auto interval(Duration period) -> typename std::enable_if< detail::defer_interval< Duration, identity_one_worker >::value, typename detail::defer_interval< Duration, identity_one_worker >::observable_type >::type
Definition: rx-interval.hpp:113