8#ifndef DATAHANDLINGLIBS_INCLUDE_DATAHANDLINGLIBS_MODELS_SKIPLISTLATENCYBUFFERMODEL_HPP_
9#define DATAHANDLINGLIBS_INCLUDE_DATAHANDLINGLIBS_MODELS_SKIPLISTLATENCYBUFFERMODEL_HPP_
17#include "folly/ConcurrentSkipList.h"
25namespace datahandlinglibs {
33 using SkipListT =
typename folly::ConcurrentSkipList<T>;
35 using SkipListTAcc =
typename folly::ConcurrentSkipList<T>::Accessor;
42 TLOG(TLVL_WORK_STEPS) <<
"Initializing non configured latency buffer";
86 void scrap(
const nlohmann::json& )
override
98 bool write(T&& new_element)
override;
99 bool put(T& new_element);
100 bool read(T& element)
override;
104 TLOG(TLVL_DEBUG) <<
"SkipListLatencyBufferModel::allocate_memory not implemented.";
110 Iterator
lower_bound(T& element,
bool with_errors=
false);
113 const T*
front()
override;
114 const T*
back()
override;
117 void pop(
size_t num = 1)
override;
size_t occupancy() const override
Occupancy of LB.
std::shared_ptr< SkipListT > m_skip_list
Iterator lower_bound(T &element, bool with_errors=false)
std::shared_ptr< SkipListT > & get_skip_list()
typename folly::ConcurrentSkipList< T >::Skipper SkipListTSkip
typename folly::ConcurrentSkipList< T >::Accessor SkipListTAcc
void scrap(const nlohmann::json &) override
Unconfigure the LB.
static constexpr uint32_t unconfigured_head_height
SkipListLatencyBufferModel()
bool read(T &element) override
Move object from LB to referenced.
typename SkipListT::iterator SkipListTIter
virtual void generate_opmon_data() override
typename folly::ConcurrentSkipList< T > SkipListT
bool write(T &&new_element) override
Move referenced object into LB.
const T * back() override
Get pointer to the back of the LB.
void conf(const appmodel::LatencyBuffer *) override
Configure the LB.
void flush() override
Flush all elements from the latency buffer.
void pop(size_t num=1) override
void allocate_memory(size_t) override
Whether or not the buffer is allocatable. false by default.
const T * front() override
Write referenced object into LB without moving it.
Iterator(SkipListTAcc &&acc, SkipListTIter iter)
friend bool operator!=(const Iterator &a, const Iterator &b)
std::ptrdiff_t difference_type
reference operator*() const
std::forward_iterator_tag iterator_category
friend bool operator==(const Iterator &a, const Iterator &b)