artdaq_core
v3_01_04
|
#include <artdaq-core/Core/ConcurrentQueue.hh>
Public Types | |
typedef EnqPolicy::ValueType | ValueType |
Type of values stored in ConcurrentQueue. | |
typedef EnqPolicy::SequenceType | SequenceType |
Type of sequence used by ConcurrentQueue. | |
typedef SequenceType::size_type | SizeType |
Type for indexes in sequence. | |
Public Member Functions | |
ConcurrentQueue (SizeType maxSize=std::numeric_limits< SizeType >::max(), detail::MemoryType maxMemory=std::numeric_limits< detail::MemoryType >::max()) | |
ConcurrentQueue is always bounded. By default, the bound is absurdly large. More... | |
~ConcurrentQueue () | |
EnqPolicy::ReturnType | enqNowait (T const &item) |
Add a copy if item to the queue, according to the rules determined by the EnqPolicy. More... | |
void | enqWait (T const &item) |
Add a copy of item to the queue. More... | |
bool | enqTimedWait (T const &item, detail::seconds const &wait) |
Add a copy of item to the queue, waiting for the queue to be non-full. More... | |
bool | deqNowait (ValueType &item) |
Assign the value at the head of the queue to item and then remove the head of the queue. More... | |
void | deqWait (ValueType &item) |
Assign the value of the head of the queue to item and then remove the head of the queue. More... | |
bool | deqTimedWait (ValueType &item, detail::seconds const &wait) |
Assign the value at the head of the queue to item and then remove the head of the queue. More... | |
bool | empty () const |
bool | full () const |
SizeType | size () const |
SizeType | capacity () const |
Return the capacity of the queue, that is, the maximum number of items it can contain. More... | |
bool | setCapacity (SizeType capacity) |
detail::MemoryType | used () const |
Return the memory in bytes used by items in the queue. More... | |
detail::MemoryType | memory () const |
Return the memory of the queue in bytes, that is, the maximum memory the items in the queue may occupy. More... | |
bool | setMemory (detail::MemoryType maxMemory) |
Reset the memory usage in bytes of the queue. A value of 0 disabled the memory check. This can only be done if the queue is empty. More... | |
SizeType | clear () |
Remove all items from the queue. This changes the size to zero but does not change the capacity. More... | |
void | addExternallyDroppedEvents (SizeType dropped) |
Adds the passed count to the counter of dropped events. More... | |
bool | queueReaderIsReady () const |
Is the reader connected and ready for items to appear on the queue? More... | |
void | setReaderIsReady (bool rdy=true) |
Set the ready flag for the reader. More... | |
std::chrono::steady_clock::time_point | getReadyTime () const |
Gets the time at which the queue became ready. More... | |
ConcurrentQueue<T> class template declaration.
Definition at line 417 of file ConcurrentQueue.hh.
|
explicit |
ConcurrentQueue is always bounded. By default, the bound is absurdly large.
maxSize | Maximum size of the ConcurrentQueue (default: SizeType::max) |
maxMemory | Maximum memory size of the ConcurrentQueue (default: MemoryType::max) |
Definition at line 711 of file ConcurrentQueue.hh.
artdaq::ConcurrentQueue< T, EnqPolicy >::~ConcurrentQueue | ( | ) |
Applications should arrange to make sure that the destructor of a ConcurrentQueue is not called while some other thread is using that queue. There is some protection against doing this, but it seems impossible to make sufficient protection.
Definition at line 726 of file ConcurrentQueue.hh.
void artdaq::ConcurrentQueue< T, EnqPolicy >::addExternallyDroppedEvents | ( | SizeType | dropped | ) |
Adds the passed count to the counter of dropped events.
dropped | Number of events dropped by code outside ConcurrentQueue |
Definition at line 896 of file ConcurrentQueue.hh.
ConcurrentQueue< T, EnqPolicy >::SizeType artdaq::ConcurrentQueue< T, EnqPolicy >::capacity | ( | ) | const |
Return the capacity of the queue, that is, the maximum number of items it can contain.
Definition at line 839 of file ConcurrentQueue.hh.
ConcurrentQueue< T, EnqPolicy >::SizeType artdaq::ConcurrentQueue< T, EnqPolicy >::clear | ( | ) |
Remove all items from the queue. This changes the size to zero but does not change the capacity.
Definition at line 883 of file ConcurrentQueue.hh.
bool artdaq::ConcurrentQueue< T, EnqPolicy >::deqNowait | ( | ValueType & | item | ) |
Assign the value at the head of the queue to item and then remove the head of the queue.
item | Reference to output item |
Assign the value at the head of the queue to item and then remove the head of the queue. If successful, return true; on failure, return false. This function fill fail without waiting if the queue is empty. This function may throw any exception thrown by the assignment operator of type EnqPolicy::ValueType.
Definition at line 779 of file ConcurrentQueue.hh.
bool artdaq::ConcurrentQueue< T, EnqPolicy >::deqTimedWait | ( | ValueType & | item, |
detail::seconds const & | wait | ||
) |
Assign the value at the head of the queue to item and then remove the head of the queue.
item | Reference to output item |
wait | Maximum number of seconds to wait for dequeue |
Assign the value at the head of the queue to item and then remove the head of the queue. If the queue is empty wait until is has become non-empty or until timeDuration has passed. Return true if an item has been removed from the queue or false if the timeout has expired. This may throw any exception thrown by the assignment operator of type EnqPolicy::ValueType.
Definition at line 799 of file ConcurrentQueue.hh.
void artdaq::ConcurrentQueue< T, EnqPolicy >::deqWait | ( | ValueType & | item | ) |
Assign the value of the head of the queue to item and then remove the head of the queue.
item | Reference to output item |
Assign the value of the head of the queue to item and then remove the head of the queue. If the queue is empty wait until is has become non-empty. This may throw any exception thrown by the assignment operator of type EnqPolicy::ValueType.
Definition at line 789 of file ConcurrentQueue.hh.
bool artdaq::ConcurrentQueue< T, EnqPolicy >::empty | ( | ) | const |
Return true if the queue is empty, and false if it is not.
Definition at line 815 of file ConcurrentQueue.hh.
EnqPolicy::ReturnType artdaq::ConcurrentQueue< T, EnqPolicy >::enqNowait | ( | T const & | item | ) |
Add a copy if item to the queue, according to the rules determined by the EnqPolicy.
Copying a ConcurrentQueue is illegal, as is asigning to a ConcurrentQueue. The copy constructor and copy assignment operator are both private and deleted.
item | Item to enqueue |
Add a copy if item to the queue, according to the rules determined by the EnqPolicy; see documentation above the the provided EnqPolicy choices. This may throw any exception thrown by the assignment operator of type T, or badAlloc.
Definition at line 739 of file ConcurrentQueue.hh.
bool artdaq::ConcurrentQueue< T, EnqPolicy >::enqTimedWait | ( | T const & | item, |
detail::seconds const & | wait | ||
) |
Add a copy of item to the queue, waiting for the queue to be non-full.
item | Item to enqueue |
wait | Maximum time (in seconds) to wait for queue to be non-full |
Add a copy of item to the queue. If the queue is full wait until it becomes non-full or until timeDuration has passed. Return true if the items has been put onto the queue or false if the timeout has expired. This may throw any exception thrown by the assignment operator of T, or badAlloc.
Definition at line 761 of file ConcurrentQueue.hh.
void artdaq::ConcurrentQueue< T, EnqPolicy >::enqWait | ( | T const & | item | ) |
Add a copy of item to the queue.
item | Item to enqueue |
Add a copy of item to the queue. If the queue is full wait until it becomes non-full. This may throw any exception thrown by the assignment operator of type T, or badAlloc.
Definition at line 750 of file ConcurrentQueue.hh.
bool artdaq::ConcurrentQueue< T, EnqPolicy >::full | ( | ) | const |
Return true if the queue is full, and false if it is not.
Definition at line 823 of file ConcurrentQueue.hh.
|
inline |
Gets the time at which the queue became ready.
Definition at line 621 of file ConcurrentQueue.hh.
detail::MemoryType artdaq::ConcurrentQueue< T, EnqPolicy >::memory | ( | ) | const |
Return the memory of the queue in bytes, that is, the maximum memory the items in the queue may occupy.
Definition at line 865 of file ConcurrentQueue.hh.
|
inline |
Is the reader connected and ready for items to appear on the queue?
Definition at line 602 of file ConcurrentQueue.hh.
bool artdaq::ConcurrentQueue< T, EnqPolicy >::setCapacity | ( | SizeType | capacity | ) |
Reset the capacity of the queue. This can only be done if the queue is empty. This function returns false if the queue was not modified, and true if it was modified.
capacity | The new capacity of the queue |
Definition at line 847 of file ConcurrentQueue.hh.
bool artdaq::ConcurrentQueue< T, EnqPolicy >::setMemory | ( | detail::MemoryType | maxMemory | ) |
Reset the memory usage in bytes of the queue. A value of 0 disabled the memory check. This can only be done if the queue is empty.
maxMemory | Sets the maximum amount of memory used by the queue |
Definition at line 873 of file ConcurrentQueue.hh.
|
inline |
Set the ready flag for the reader.
rdy | Value of the ready flag (default: true) |
Sets the ready flag for the reader, and the time that the reader became ready or unready. Used to help artdaq wait for art to finish initializing.
Definition at line 611 of file ConcurrentQueue.hh.
ConcurrentQueue< T, EnqPolicy >::SizeType artdaq::ConcurrentQueue< T, EnqPolicy >::size | ( | ) | const |
Return the size of the queue, that is, the number of items it contains.
Definition at line 831 of file ConcurrentQueue.hh.
detail::MemoryType artdaq::ConcurrentQueue< T, EnqPolicy >::used | ( | ) | const |
Return the memory in bytes used by items in the queue.
Definition at line 857 of file ConcurrentQueue.hh.