Template Class ThreadsafeTemporalBuffer

Class Documentation

template<typename ValueType, typename AllocatorType = std::allocator<std::pair<int64_t, ValueType>>>
class common::ThreadsafeTemporalBuffer

Public Types

enum QueryResult

Values:

enumerator kDataAvailable

Query was successful and the data is available.

enumerator kDataNotYetAvailable

The required data is not (yet) available.

The query timestamp is above the last sample’s time.

enumerator kDataNeverAvailable

The queried timestamp lies before the first sample in the buffer.

This request will never succeed considering chronological ordering of the buffer input data.

enumerator kQueueShutdown
enumerator kTooFewMeasurementsAvailable
typedef TemporalBuffer<ValueType, AllocatorType>::BufferType BufferType
typedef std::function<void(const typename BufferType::value_type&)> ForEachFunction

Public Functions

inline ThreadsafeTemporalBuffer()
inline explicit ThreadsafeTemporalBuffer(const int64_t buffer_length_ns)
inline ~ThreadsafeTemporalBuffer()
inline void shutdown()

Shutdown the queue and release all blocked waiters.

inline bool addValue(const int64_t timestamp_nanoseconds, const ValueType &value)
inline bool pushBack(const int64_t timestamp_nanoseconds, const ValueType &value)
inline bool empty() const
inline size_t size() const
template<typename ContainerType>
QueryResult getInterpolatedBorders(const int64_t timestamp_from, const int64_t timestamp_to, ContainerType *values) const

Return a list of the buffer values between the specified timestamps.

The values get interpolated if the queried timestamp does not match a buffer value. The return code signals if the buffer does not contain data up to the requested timestamp. In this case the output values with be empty.

template<typename ContainerType>
QueryResult getInterpolatedBordersBlocking(const int64_t timestamp_ns_from, int64_t timestamp_ns_to, const int64_t wait_timeout_nanoseconds, ContainerType *values) const

Try to fetch the requested buffer values for the duration of wait_timeout_nanoseconds.

If the requested data is still not available when timeout has been reached, the method will return false and no data will be removed from the buffer.

template<typename ContainerType>
QueryResult getValuesFromExcludingToIncludingBlocking(const int64_t timestamp_ns_from, int64_t timestamp_ns_to, const int64_t wait_timeout_nanoseconds, ContainerType *values) const
inline bool getNearestValueToTime(const int64_t timestamp, const int64_t maximum_delta_ns, ValueType *value, int64_t *timestamp_at_value_ns)
inline bool getNearestValueToTime(const int64_t timestamp, const int64_t maximum_delta_ns, ValueType *value)
inline void forEach(const ForEachFunction &for_each_function)

Public Members

ThreadsafeTemporalBuffer