artdaq::ConcurrentQueue< T, EnqPolicy > Class Template Reference

#include <artdaq-core/Core/ConcurrentQueue.hh>

List of all members.

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.
 ~ConcurrentQueue ()
EnqPolicy::ReturnType enqNowait (T const &item)
 Add a copy if item to the queue, according to the rules determined by the EnqPolicy.
void enqWait (T const &item)
 Add a copy of item to the queue.
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.
bool deqNowait (ValueType &item)
 Assign the value at the head of the queue to item and then remove the head of the queue.
void deqWait (ValueType &item)
 Assign the value of the head of the queue to item and then remove the head of the queue.
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.
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.
bool setCapacity (SizeType capacity)
detail::MemoryType used () const
 Return the memory in bytes used by items in the queue.
detail::MemoryType memory () const
 Return the memory of the queue in bytes, that is, the maximum memory the items in the queue may occupy.
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.
SizeType clear ()
 Remove all items from the queue. This changes the size to zero but does not change the capacity.
void addExternallyDroppedEvents (SizeType dropped)
 Adds the passed count to the counter of dropped events.
bool queueReaderIsReady () const
 Is the reader connected and ready for items to appear on the queue?
void setReaderIsReady (bool rdy=true)
 Set the ready flag for the reader.
std::chrono::steady_clock::time_point getReadyTime () const
 Gets the time at which the queue became ready.

Detailed Description

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

ConcurrentQueue<T> class template declaration.

Definition at line 415 of file ConcurrentQueue.hh.


Constructor & Destructor Documentation

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

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

Parameters:
maxSize Maximum size of the ConcurrentQueue (default: SizeType::max)
maxMemory Maximum memory size of the ConcurrentQueue (default: MemoryType::max)

Definition at line 709 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
artdaq::ConcurrentQueue< T, EnqPolicy >::~ConcurrentQueue (  )  [inline]

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


Member Function Documentation

template<class T , class EnqPolicy >
void artdaq::ConcurrentQueue< T, EnqPolicy >::addExternallyDroppedEvents ( SizeType  dropped  )  [inline]

Adds the passed count to the counter of dropped events.

Parameters:
dropped Number of events dropped by code outside ConcurrentQueue

Definition at line 894 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
ConcurrentQueue< T, EnqPolicy >::SizeType artdaq::ConcurrentQueue< T, EnqPolicy >::capacity (  )  const [inline]

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

Returns:
The maxmium number of items the ConcurrentQueue can contain

Definition at line 837 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
ConcurrentQueue< T, EnqPolicy >::SizeType artdaq::ConcurrentQueue< T, EnqPolicy >::clear (  )  [inline]

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

template<class T , class EnqPolicy >
bool artdaq::ConcurrentQueue< T, EnqPolicy >::deqNowait ( ValueType item  )  [inline]

Assign the value at the head of the queue to item and then remove the head of the queue.

Parameters:
item Reference to output item
Returns:
If the dequeue operation was successful

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

template<class T , class EnqPolicy >
bool artdaq::ConcurrentQueue< T, EnqPolicy >::deqTimedWait ( ValueType item,
detail::seconds const &  wait 
) [inline]

Assign the value at the head of the queue to item and then remove the head of the queue.

Parameters:
item Reference to output item
wait Maximum number of seconds to wait for dequeue
Returns:
Whether an item was dequeued in the given interval

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

template<class T , class EnqPolicy >
void artdaq::ConcurrentQueue< T, EnqPolicy >::deqWait ( ValueType item  )  [inline]

Assign the value of the head of the queue to item and then remove the head of the queue.

Parameters:
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 787 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool artdaq::ConcurrentQueue< T, EnqPolicy >::empty (  )  const [inline]

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

Returns:
True if the queue is empty

Definition at line 813 of file ConcurrentQueue.hh.

template<class T, class EnqPolicy >
EnqPolicy::ReturnType artdaq::ConcurrentQueue< T, EnqPolicy >::enqNowait ( T const &  item  )  [inline]

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.

Parameters:
item Item to enqueue
Returns:
EnqPolicy::ReturnType result of enqueue operation

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

template<class T, class EnqPolicy >
bool artdaq::ConcurrentQueue< T, EnqPolicy >::enqTimedWait ( T const &  item,
detail::seconds const &  wait 
) [inline]

Add a copy of item to the queue, waiting for the queue to be non-full.

Parameters:
item Item to enqueue
wait Maximum time (in seconds) to wait for queue to be non-full
Returns:
Whether the item was added before the timeout expired

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

template<class T, class EnqPolicy >
void artdaq::ConcurrentQueue< T, EnqPolicy >::enqWait ( T const &  item  )  [inline]

Add a copy of item to the queue.

Parameters:
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 748 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool artdaq::ConcurrentQueue< T, EnqPolicy >::full (  )  const [inline]

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

Returns:
True if the queue is full

Definition at line 821 of file ConcurrentQueue.hh.

template<class T, class EnqPolicy = FailIfFull<T>>
std::chrono::steady_clock::time_point artdaq::ConcurrentQueue< T, EnqPolicy >::getReadyTime (  )  const [inline]

Gets the time at which the queue became ready.

Returns:
Time at which the queue became ready

Definition at line 619 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
detail::MemoryType artdaq::ConcurrentQueue< T, EnqPolicy >::memory (  )  const [inline]

Return the memory of the queue in bytes, that is, the maximum memory the items in the queue may occupy.

Returns:
The amount of memory allocated by the queue

Definition at line 863 of file ConcurrentQueue.hh.

template<class T, class EnqPolicy = FailIfFull<T>>
bool artdaq::ConcurrentQueue< T, EnqPolicy >::queueReaderIsReady (  )  const [inline]

Is the reader connected and ready for items to appear on the queue?

Returns:
If the reader is connected and ready for items to be written to the queue.

Definition at line 600 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool artdaq::ConcurrentQueue< T, EnqPolicy >::setCapacity ( SizeType  capacity  )  [inline]

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.

Parameters:
capacity The new capacity of the queue
Returns:
True if the queue was modified

Definition at line 845 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
bool artdaq::ConcurrentQueue< T, EnqPolicy >::setMemory ( detail::MemoryType  maxMemory  )  [inline]

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.

Parameters:
maxMemory Sets the maximum amount of memory used by the queue
Returns:
This function returns false if the queue was not modified, and true if it was modified.

Definition at line 871 of file ConcurrentQueue.hh.

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

Set the ready flag for the reader.

Parameters:
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 609 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
ConcurrentQueue< T, EnqPolicy >::SizeType artdaq::ConcurrentQueue< T, EnqPolicy >::size (  )  const [inline]

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

Returns:
The number of items in the queue

Definition at line 829 of file ConcurrentQueue.hh.

template<class T , class EnqPolicy >
detail::MemoryType artdaq::ConcurrentQueue< T, EnqPolicy >::used (  )  const [inline]

Return the memory in bytes used by items in the queue.

Returns:
The amount of memory in use by queue items

Definition at line 855 of file ConcurrentQueue.hh.


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

Generated on 5 Feb 2019 for artdaq_core by  doxygen 1.6.1