DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SkipListLatencyBufferModel.hxx
Go to the documentation of this file.
1// Declarations for SkipListLatencyBufferModel
2
3namespace dunedaq {
4namespace datahandlinglibs {
5
6template<class T>
7size_t
9{
10 auto occupancy = 0;
11 {
12 SkipListTAcc acc(m_skip_list);
13 occupancy = acc.size();
14 }
15 return occupancy;
16}
17
18template<class T>
19bool
21{
22 bool success = false;
23 {
24 SkipListTAcc acc(m_skip_list);
25 auto ret = acc.insert(std::move(new_element)); // ret T = std::pair<iterator, bool>
26 success = ret.second;
27 }
28 return success;
29}
30
31template<class T>
32bool
34{
35 bool success = false;
36 {
37 SkipListTAcc acc(m_skip_list);
38 auto ret = acc.insert(new_element); // ret T = std::pair<iterator, bool>
39 success = ret.second;
40 }
41 return success;
42}
43
44template<class T>
45bool
47{
48 bool found = false;
49 {
50 SkipListTAcc acc(m_skip_list);
51 auto lb_node = acc.begin();
52 found = (lb_node == acc.end()) ? false : true;
53 if (found) {
54 element = *lb_node;
55 }
56 }
57 return found;
58}
59
60template<class T>
63{
64 SkipListTAcc acc = SkipListTAcc(m_skip_list);
65 SkipListTIter iter = acc.begin();
66 return std::move(SkipListLatencyBufferModel<T>::Iterator(std::move(acc), iter));
67}
68
69template<class T>
72{
73 SkipListTAcc acc = SkipListTAcc(m_skip_list);
74 SkipListTIter iter = acc.end();
75 return std::move(SkipListLatencyBufferModel<T>::Iterator(std::move(acc), iter));
76}
77
78template<class T>
80SkipListLatencyBufferModel<T>::lower_bound(T& element, bool /*with_errors=false*/)
81{
82 SkipListTAcc acc = SkipListTAcc(m_skip_list);
83 SkipListTIter iter = acc.lower_bound(element);
84 return std::move(SkipListLatencyBufferModel<T>::Iterator(std::move(acc), iter));
85}
86
87template<class T>
88const T*
90{
91 SkipListTAcc acc(m_skip_list);
92 return acc.first();
93}
94
95template<class T>
96const T*
98{
99 SkipListTAcc acc(m_skip_list);
100 return acc.last();
101}
102
103template<class T>
104void
105SkipListLatencyBufferModel<T>::pop(size_t num) // NOLINT(build/unsigned)
106{
107 {
108 SkipListTAcc acc(m_skip_list);
109 for (unsigned i = 0; i < num; ++i) {
110 acc.pop_back();
111 }
112 }
113}
114
115template<class T>
116void
119 info.set_num_buffer_elements(occupancy());
120 this->publish(std::move(info));
121}
122
123} // namespace datahandlinglibs
124} // namespace dunedaq
Iterator lower_bound(T &element, bool with_errors=false)
typename folly::ConcurrentSkipList< T >::Accessor SkipListTAcc
bool read(T &element) override
Move object from LB to referenced.
bool write(T &&new_element) override
Move referenced object into LB.
const T * back() override
Get pointer to the back of the LB.
const T * front() override
Write referenced object into LB without moving it.
Including Qt Headers.