DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::datahandlinglibs::BinarySearchQueueModel< T > Class Template Reference

#include <BinarySearchQueueModel.hpp>

Inheritance diagram for dunedaq::datahandlinglibs::BinarySearchQueueModel< T >:
[legend]
Collaboration diagram for dunedaq::datahandlinglibs::BinarySearchQueueModel< T >:
[legend]

Public Member Functions

 BinarySearchQueueModel ()
 
 BinarySearchQueueModel (uint32_t size)
 
IterableQueueModel< T >::Iterator lower_bound (T &element, bool=false)
 
- Public Member Functions inherited from dunedaq::datahandlinglibs::IterableQueueModel< T >
 IterableQueueModel (const IterableQueueModel &)=delete
 
IterableQueueModeloperator= (const IterableQueueModel &)=delete
 
 IterableQueueModel ()
 
 IterableQueueModel (std::size_t size)
 
 IterableQueueModel (std::size_t size, bool numa_aware=false, uint8_t numa_node=0, bool intrinsic_allocator=false, std::size_t alignment_size=0)
 
 ~IterableQueueModel ()
 
void free_memory ()
 
void allocate_memory (std::size_t size, bool numa_aware, uint8_t numa_node=0, bool intrinsic_allocator=false, std::size_t alignment_size=0)
 
void allocate_memory (std::size_t size) override
 
void prefill_task ()
 
void force_pagefault ()
 
bool write (T &&record) override
 Move referenced object into LB.
 
bool read (T &record) override
 Move object from LB to referenced.
 
void popFront ()
 
void pop (std::size_t x)
 Pop specified amount of elements from LB.
 
bool isEmpty () const
 
bool isFull () const
 
std::size_t occupancy () const override
 Occupancy of LB.
 
std::size_t size () const
 
std::size_t capacity () const
 
const T * front () override
 Write referenced object into LB without moving it.
 
const T * back () override
 Get pointer to the back of the LB.
 
T * start_of_buffer ()
 
T * end_of_buffer ()
 
void conf (const appmodel::LatencyBuffer *cfg) override
 Configure the LB.
 
void scrap (const nlohmann::json &) override
 Unconfigure the LB.
 
void flush () override
 Flush all elements from the latency buffer.
 
std::size_t get_alignment_size ()
 
Iterator begin ()
 
Iterator end ()
 
- Public Member Functions inherited from dunedaq::datahandlinglibs::LatencyBufferConcept< T >
 LatencyBufferConcept ()
 
virtual ~LatencyBufferConcept ()
 
 LatencyBufferConcept (const LatencyBufferConcept &)=delete
 LatencyBufferConcept is not copy-constructible.
 
LatencyBufferConceptoperator= (const LatencyBufferConcept &)=delete
 LatencyBufferConcept is not copy-assginable.
 
 LatencyBufferConcept (LatencyBufferConcept &&)=delete
 LatencyBufferConcept is not move-constructible.
 
LatencyBufferConceptoperator= (LatencyBufferConcept &&)=delete
 LatencyBufferConcept is not move-assignable.
 
virtual void allocate_memory (size_t)=0
 Whether or not the buffer is allocatable. false by default.
 
- Public Member Functions inherited from dunedaq::opmonlib::MonitorableObject
 MonitorableObject (const MonitorableObject &)=delete
 
MonitorableObjectoperator= (const MonitorableObject &)=delete
 
 MonitorableObject (MonitorableObject &&)=delete
 
MonitorableObjectoperator= (MonitorableObject &&)=delete
 
virtual ~MonitorableObject ()=default
 
auto get_opmon_id () const noexcept
 
auto get_opmon_level () const noexcept
 

Additional Inherited Members

- Public Types inherited from dunedaq::datahandlinglibs::IterableQueueModel< T >
typedef T value_type
 
- Public Types inherited from dunedaq::opmonlib::MonitorableObject
using NodePtr = std::weak_ptr<MonitorableObject>
 
using NewNodePtr = std::shared_ptr<MonitorableObject>
 
using ElementId = std::string
 
- Static Public Member Functions inherited from dunedaq::opmonlib::MonitorableObject
static bool publishable_metric (OpMonLevel entry, OpMonLevel system) noexcept
 
- Protected Member Functions inherited from dunedaq::datahandlinglibs::IterableQueueModel< T >
virtual void generate_opmon_data () override
 
template<class... Args>
bool write_ (Args &&... recordArgs)
 
- Protected Member Functions inherited from dunedaq::opmonlib::MonitorableObject
 MonitorableObject ()=default
 
void register_node (ElementId name, NewNodePtr)
 
void publish (google::protobuf::Message &&, CustomOrigin &&co={}, OpMonLevel l=to_level(EntryOpMonLevel::kDefault)) const noexcept
 
- Protected Attributes inherited from dunedaq::datahandlinglibs::IterableQueueModel< T >
std::atomic< int > overflow_ctr { 0 }
 
bool numa_aware_
 
uint8_t numa_node_
 
bool intrinsic_allocator_
 
std::size_t alignment_size_
 
bool invalid_configuration_requested_
 
std::string prefiller_name_ {"lbpfn"}
 
std::mutex prefill_mutex_
 
std::condition_variable prefill_cv_
 
bool prefill_ready_
 
bool prefill_done_
 
std::thread ptrlogger
 
char pad0_ [folly::hardware_destructive_interference_size]
 
uint32_t size_
 
T * records_
 
std::atomic< unsigned int > readIndex_
 
std::atomic< unsigned int > writeIndex_
 
char pad1_ [folly::hardware_destructive_interference_size - sizeof(writeIndex_)]
 

Detailed Description

template<class T>
class dunedaq::datahandlinglibs::BinarySearchQueueModel< T >

Definition at line 22 of file BinarySearchQueueModel.hpp.

Constructor & Destructor Documentation

◆ BinarySearchQueueModel() [1/2]

template<class T >
dunedaq::datahandlinglibs::BinarySearchQueueModel< T >::BinarySearchQueueModel ( )
inline

◆ BinarySearchQueueModel() [2/2]

template<class T >
dunedaq::datahandlinglibs::BinarySearchQueueModel< T >::BinarySearchQueueModel ( uint32_t size)
inlineexplicit

Member Function Documentation

◆ lower_bound()

template<typename T >
IterableQueueModel< T >::Iterator dunedaq::datahandlinglibs::BinarySearchQueueModel< T >::lower_bound ( T & element,
bool = false )

Definition at line 8 of file BinarySearchQueueModel.hxx.

9{
10 unsigned int start_index =
11 IterableQueueModel<T>::readIndex_.load(std::memory_order_relaxed); // NOLINT(build/unsigned)
12 unsigned int end_index =
13 IterableQueueModel<T>::writeIndex_.load(std::memory_order_acquire); // NOLINT(build/unsigned)
14
15 if (start_index == end_index) {
16 TLOG() << "Queue is empty" << std::endl;
18 }
19 end_index = end_index == 0 ? IterableQueueModel<T>::size_ - 1 : end_index - 1;
20
21 T& left_element = IterableQueueModel<T>::records_[start_index];
22
23 if (element < left_element) {
24 TLOG() << "Could not find element" << std::endl;
26 }
27
28 while (true) {
29 unsigned int diff =
30 start_index <= end_index ? end_index - start_index : IterableQueueModel<T>::size_ + end_index - start_index;
31 unsigned int middle_index = start_index + ((diff + 1) / 2);
32 if (middle_index >= IterableQueueModel<T>::size_)
33 middle_index -= IterableQueueModel<T>::size_;
34 T& element_between = IterableQueueModel<T>::records_[middle_index];
35
36 //if we landed on our element, let's get out of here.
37 if (element.get_timestamp()==element_between.get_timestamp())
38 return typename IterableQueueModel<T>::Iterator(*this, middle_index);
39
40 if ( diff == 0 ) {
41
42 //if we satisfy the lower_bound condition, we have the right index
43 if(element < element_between)
44 return typename IterableQueueModel<T>::Iterator(*this, middle_index);
45
46 //if we don't, we need to increment one up. for safety check size too
47 if(++middle_index >= IterableQueueModel<T>::size_)
48 middle_index -= IterableQueueModel<T>::size_;
49
50 return typename IterableQueueModel<T>::Iterator(*this, middle_index);
51 }
52
53 if (element < element_between) {
54 end_index = middle_index != 0 ? middle_index - 1 : IterableQueueModel<T>::size_ - 1;
55 } else {
56 start_index = middle_index;
57 }
58 }
59}
#define TLOG(...)
Definition macro.hpp:22

The documentation for this class was generated from the following files: