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
4
5namespace dunedaq {
6namespace datahandlinglibs {
7
8template<class T>
9size_t
11{
12 auto occupancy = 0;
13 {
14 SkipListTAcc acc(m_skip_list);
15 occupancy = acc.size();
16 }
17 return occupancy;
18}
19
20template<class T>
21bool
23{
24 bool success = false;
25 {
26 SkipListTAcc acc(m_skip_list);
27 auto ret = acc.insert(std::move(new_element)); // ret T = std::pair<iterator, bool>
28 success = ret.second;
29 }
30 return success;
31}
32
33template<class T>
34bool
36{
37 bool success = false;
38 {
39 SkipListTAcc acc(m_skip_list);
40 auto ret = acc.insert(new_element); // ret T = std::pair<iterator, bool>
41 success = ret.second;
42 }
43 return success;
44}
45
46template<class T>
47bool
49{
50 bool found = false;
51 {
52 SkipListTAcc acc(m_skip_list);
53 auto lb_node = acc.begin();
54 found = (lb_node == acc.end()) ? false : true;
55 if (found) {
56 element = *lb_node;
57 }
58 }
59 return found;
60}
61
62template<class T>
65{
66 SkipListTAcc acc = SkipListTAcc(m_skip_list);
67 SkipListTIter iter = acc.begin();
68 return std::move(SkipListLatencyBufferModel<T>::Iterator(std::move(acc), iter));
69}
70
71template<class T>
74{
75 SkipListTAcc acc = SkipListTAcc(m_skip_list);
76 SkipListTIter iter = acc.end();
77 return std::move(SkipListLatencyBufferModel<T>::Iterator(std::move(acc), iter));
78}
79
80template<class T>
82SkipListLatencyBufferModel<T>::lower_bound(T& element, bool /*with_errors=false*/)
83{
84 SkipListTAcc acc = SkipListTAcc(m_skip_list);
85 SkipListTIter iter = acc.lower_bound(element);
86 return std::move(SkipListLatencyBufferModel<T>::Iterator(std::move(acc), iter));
87}
88
89template<class T>
90const T*
92{
93 SkipListTAcc acc(m_skip_list);
94 return acc.first();
95}
96
97template<class T>
98const T*
100{
101 SkipListTAcc acc(m_skip_list);
102 return acc.last();
103}
104
105template<class T>
106void
107SkipListLatencyBufferModel<T>::pop(size_t num) // NOLINT(build/unsigned)
108{
109 {
110 SkipListTAcc acc(m_skip_list);
111 for (unsigned i = 0; i < num; ++i) {
112 acc.pop_back();
113 }
114 }
115}
116
117template<class T>
118void
121 info.set_num_buffer_elements(occupancy());
122 this->publish(std::move(info));
123}
124
125} // namespace datahandlinglibs
126} // 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.
The DUNE-DAQ namespace.