artdaq_core  v1_07_00
 All Classes Namespaces Functions
Public Types | Public Member Functions | List of all members
daqrate::ConcurrentQueue< T, EnqPolicy > Class Template Reference

#include <ConcurrentQueue.hh>

Public Types

typedef EnqPolicy::ValueType ValueType
 
typedef EnqPolicy::SequenceType SequenceType
 
typedef SequenceType::size_type SizeType
 

Public Member Functions

 ConcurrentQueue (SizeType maxSize=std::numeric_limits< SizeType >::max(), detail::MemoryType maxMemory=std::numeric_limits< detail::MemoryType >::max())
 
 ~ConcurrentQueue ()
 
EnqPolicy::ReturnType enqNowait (T const &item)
 
void enqWait (T const &p)
 
bool enqTimedWait (T const &p, seconds const &)
 
bool deqNowait (ValueType &)
 
void deqWait (ValueType &)
 
bool deqTimedWait (ValueType &, seconds const &)
 
bool empty () const
 
bool full () const
 
SizeType size () const
 
SizeType capacity () const
 
bool setCapacity (SizeType n)
 
detail::MemoryType used () const
 
detail::MemoryType memory () const
 
bool setMemory (detail::MemoryType n)
 
SizeType clear ()
 
void addExternallyDroppedEvents (SizeType)
 
bool queueReaderIsReady ()
 
void setReaderIsReady (bool rdy=true)
 
std::chrono::steady_clock::time_point getReadyTime ()
 

Detailed Description

template<class T, class EnqPolicy = FailIfFull<T>>
class daqrate::ConcurrentQueue< T, EnqPolicy >

ConcurrentQueue<T> class template declaration.

Definition at line 280 of file ConcurrentQueue.hh.

Constructor & Destructor Documentation

template<class T , class EnqPolicy >
daqrate::ConcurrentQueue< T, EnqPolicy >::ConcurrentQueue ( SizeType  maxSize = std::numeric_limits<SizeType>::max(),
detail::MemoryType  maxMemory = std::numeric_limits<detail::MemoryType>::max() 
)
explicit

ConcurrentQueue is always bounded. By default, the bound is absurdly large.

Definition at line 516 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
daqrate::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 532 of file ConcurrentQueue.hh.

Member Function Documentation

template<class T , class EnqPolicy >
void daqrate::ConcurrentQueue< T, EnqPolicy >::addExternallyDroppedEvents ( SizeType  n)

Adds the passed count to the counter of dropped events

Definition at line 702 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
ConcurrentQueue< T, EnqPolicy >::SizeType daqrate::ConcurrentQueue< T, EnqPolicy >::capacity ( ) const

Return the capacity of the queue, that is, the maximum number of items it can contain.

Definition at line 645 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
ConcurrentQueue< T, EnqPolicy >::SizeType daqrate::ConcurrentQueue< T, EnqPolicy >::clear ( )

Remove all items from the queue. This changes the size to zero but does not change the capacity. Returns the number of cleared events.

Definition at line 689 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool daqrate::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. 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 584 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool daqrate::ConcurrentQueue< T, EnqPolicy >::deqTimedWait ( ValueType &  item,
seconds const &  waitTime 
)

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 604 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
void daqrate::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. 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 594 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool daqrate::ConcurrentQueue< T, EnqPolicy >::empty ( ) const

Return true if the queue is empty, and false if it is not.

Definition at line 621 of file ConcurrentQueue.hh.

template<class T, class EnqPolicy >
EnqPolicy::ReturnType daqrate::ConcurrentQueue< T, EnqPolicy >::enqNowait ( T const &  item)

Copying a ConcurrentQueue is illegal, as is asigning to a ConcurrentQueue. The copy constructor and copy assignment operator are both private and unimplemented. 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 545 of file ConcurrentQueue.hh.

template<class T, class EnqPolicy >
bool daqrate::ConcurrentQueue< T, EnqPolicy >::enqTimedWait ( T const &  p,
seconds const &  waitTime 
)

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 567 of file ConcurrentQueue.hh.

template<class T, class EnqPolicy >
void daqrate::ConcurrentQueue< T, EnqPolicy >::enqWait ( T const &  p)

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 556 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool daqrate::ConcurrentQueue< T, EnqPolicy >::full ( ) const

Return true if the queue is full, and false if it is not.

Definition at line 629 of file ConcurrentQueue.hh.

template<class T, class EnqPolicy = FailIfFull<T>>
std::chrono::steady_clock::time_point daqrate::ConcurrentQueue< T, EnqPolicy >::getReadyTime ( )
inline

Gets the time at which the ready became ready

Definition at line 437 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
detail::MemoryType daqrate::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 671 of file ConcurrentQueue.hh.

template<class T, class EnqPolicy = FailIfFull<T>>
bool daqrate::ConcurrentQueue< T, EnqPolicy >::queueReaderIsReady ( )
inline

Indicate that the receiver is connected

Definition at line 424 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool daqrate::ConcurrentQueue< T, EnqPolicy >::setCapacity ( SizeType  n)

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.

Definition at line 653 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool daqrate::ConcurrentQueue< T, EnqPolicy >::setMemory ( detail::MemoryType  n)

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. This function returns false if the queue was not modified, and true if it was modified.

Definition at line 679 of file ConcurrentQueue.hh.

template<class T, class EnqPolicy = FailIfFull<T>>
void daqrate::ConcurrentQueue< T, EnqPolicy >::setReaderIsReady ( bool  rdy = true)
inline

Set Reader Ready

Definition at line 429 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
ConcurrentQueue< T, EnqPolicy >::SizeType daqrate::ConcurrentQueue< T, EnqPolicy >::size ( ) const

Return the size of the queue, that is, the number of items it contains.

Definition at line 637 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
detail::MemoryType daqrate::ConcurrentQueue< T, EnqPolicy >::used ( ) const

Return the memory in bytes used by items in the queue

Definition at line 663 of file ConcurrentQueue.hh.


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