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 {
15 occupancy = acc.size();
16 }
17 return occupancy;
18}
19
20template<class T>
21bool
23{
24 bool success = false;
25 {
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>
34std::pair<const T*, bool>
36{
37 const T* written = nullptr;
38 bool success = false;
39 {
41 const auto [iter, result] = acc.insert(std::move(new_element));
42 written = &(*iter);
43 success = result;
44 }
45 return {written, success};
46}
47
48template<class T>
49bool
51{
52 bool success = false;
53 {
55 auto ret = acc.insert(new_element); // ret T = std::pair<iterator, bool>
56 success = ret.second;
57 }
58 return success;
59}
60
61template<class T>
62bool
64{
65 bool found = false;
66 {
68 auto lb_node = acc.begin();
69 found = (lb_node == acc.end()) ? false : true;
70 if (found) {
71 element = *lb_node;
72 }
73 }
74 return found;
75}
76
77template<class T>
80{
82 SkipListTIter iter = acc.begin();
83 return std::move(SkipListLatencyBufferModel<T>::Iterator(std::move(acc), iter));
84}
85
86template<class T>
89{
91 SkipListTIter iter = acc.end();
92 return std::move(SkipListLatencyBufferModel<T>::Iterator(std::move(acc), iter));
93}
94
95template<class T>
97SkipListLatencyBufferModel<T>::lower_bound(T& element, bool /*with_errors=false*/)
98{
100 SkipListTIter iter = acc.lower_bound(element);
101 return std::move(SkipListLatencyBufferModel<T>::Iterator(std::move(acc), iter));
102}
103
104template<class T>
105const T*
107{
109 return acc.first();
110}
111
112template<class T>
113const T*
115{
117 return acc.last();
118}
119
120template<class T>
121void
122SkipListLatencyBufferModel<T>::pop(size_t num) // NOLINT(build/unsigned)
123{
124 {
126 for (unsigned i = 0; i < num; ++i) {
127 acc.pop_back();
128 }
129 }
130}
131
132template<class T>
133void
136 info.set_num_buffer_elements(occupancy());
137 this->publish(std::move(info));
138}
139
140} // namespace datahandlinglibs
141} // namespace dunedaq
Iterator lower_bound(T &element, bool with_errors=false)
typename folly::ConcurrentSkipList< T >::Accessor SkipListTAcc
std::pair< const T *, bool > write_and_return(T &&new_element)
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
Get pointer to the front of the LB.
void publish(google::protobuf::Message &&, CustomOrigin &&co={}, OpMonLevel l=to_level(EntryOpMonLevel::kDefault)) const noexcept
Including Qt Headers.
Definition module.cpp:16