S3FC project page | S3FC home page |
#include <s3_growable_fifo_queue.h>
Inheritance diagram for s3_growable_fifo_queue:
Public Methods | |
s3_growable_fifo_queue (int n_max_size=-1) | |
Constructor just needs to set up the mutex. More... | |
virtual | ~s3_growable_fifo_queue () |
Clean up. More... | |
void | push (const T &t) |
Wrapper around STL queue push that just locks the mutex. More... | |
T | pop () |
Remove oldest entry, blocking if the queue is empty. More... | |
bool | empty () const |
Check if queue is empty. More... | |
bool | full () const |
Returns true if the queue is full. More... | |
unsigned int | size () const |
Returns the number of elements in the queue. More... | |
Private Attributes | |
pthread_mutex_t | mutex |
If you hold this mutex, you got the queue. More... | |
pthread_mutexattr_t | m_attr |
Sets up the kind of mutex we need. More... | |
pthread_cond_t | cond_not_empty |
Signal this condition if the queue is no longer empty. More... | |
pthread_cond_t | cond_not_full |
Condition to be signalled on a pop() to indicate that there is at least one opening in the queue. More... | |
std::queue< T > | q |
STL container for the data. More... | |
int | max_size |
Maximum number of elements in the queue. More... |
This class wraps around the STL queue class and provides templated thread safe queues that are used to queue external messages and commands for display and execution. Any number of threads can push and pop data to and from this class in a safe manner.
Definition at line 50 of file s3_growable_fifo_queue.h.
|
Constructor just needs to set up the mutex. It can optionally limit the maximum size of the queue if your consumer is slower than your producer.
Definition at line 89 of file s3_growable_fifo_queue.h. |
|
Clean up.
Definition at line 99 of file s3_growable_fifo_queue.h. |
|
Check if queue is empty. Just checks if the queue is empty with locks.
Implements s3_fifo_base. Definition at line 181 of file s3_growable_fifo_queue.h. |
|
Returns true if the queue is full.
Implements s3_fifo_base. Definition at line 194 of file s3_growable_fifo_queue.h. |
|
Remove oldest entry, blocking if the queue is empty. If you want a non-blocking queue, test if the queue is empty prior to calling pop(). Note that this combines the front() and pop() commands needed to read and remove the oldest entry in the queue. It also does the necessary locking of the mutex. The calling thread will block until something arrives in the queue.
Implements s3_fifo_base. Definition at line 146 of file s3_growable_fifo_queue.h. |
|
Wrapper around STL queue push that just locks the mutex. The push will block if the queue is full, and wait until pop() has been called at least once. This call will also release any thread that is blocking on an empty queue.
Implements s3_fifo_base. Definition at line 114 of file s3_growable_fifo_queue.h. |
|
Returns the number of elements in the queue.
Implements s3_fifo_base. Definition at line 206 of file s3_growable_fifo_queue.h. |
|
Signal this condition if the queue is no longer empty. This allows the queue to block until something pitches from the sender. Definition at line 64 of file s3_growable_fifo_queue.h. Referenced by s3_growable_fifo_queue< s3_txport_event >::pop, s3_growable_fifo_queue< s3_txport_event >::push, s3_growable_fifo_queue< s3_txport_event >::s3_growable_fifo_queue, and s3_growable_fifo_queue< s3_txport_event >::~s3_growable_fifo_queue. |
|
Condition to be signalled on a pop() to indicate that there is at least one opening in the queue.
Definition at line 70 of file s3_growable_fifo_queue.h. Referenced by s3_growable_fifo_queue< s3_txport_event >::pop, s3_growable_fifo_queue< s3_txport_event >::push, s3_growable_fifo_queue< s3_txport_event >::s3_growable_fifo_queue, and s3_growable_fifo_queue< s3_txport_event >::~s3_growable_fifo_queue. |
|
Sets up the kind of mutex we need.
Definition at line 57 of file s3_growable_fifo_queue.h. Referenced by s3_growable_fifo_queue< s3_txport_event >::s3_growable_fifo_queue, and s3_growable_fifo_queue< s3_txport_event >::~s3_growable_fifo_queue. |
|
Maximum number of elements in the queue. Setting this to a non-zero value limits the size of the queue. The push() method will block until something reads from the queue. Definition at line 80 of file s3_growable_fifo_queue.h. Referenced by s3_growable_fifo_queue< s3_txport_event >::full, s3_growable_fifo_queue< s3_txport_event >::pop, s3_growable_fifo_queue< s3_txport_event >::push, and s3_growable_fifo_queue< s3_txport_event >::s3_growable_fifo_queue. |
|
If you hold this mutex, you got the queue.
Definition at line 54 of file s3_growable_fifo_queue.h. Referenced by s3_growable_fifo_queue< s3_txport_event >::empty, s3_growable_fifo_queue< s3_txport_event >::full, s3_growable_fifo_queue< s3_txport_event >::pop, s3_growable_fifo_queue< s3_txport_event >::push, s3_growable_fifo_queue< s3_txport_event >::s3_growable_fifo_queue, s3_growable_fifo_queue< s3_txport_event >::size, and s3_growable_fifo_queue< s3_txport_event >::~s3_growable_fifo_queue. |
|
STL container for the data.
Definition at line 73 of file s3_growable_fifo_queue.h. Referenced by s3_growable_fifo_queue< s3_txport_event >::empty, s3_growable_fifo_queue< s3_txport_event >::full, s3_growable_fifo_queue< s3_txport_event >::pop, s3_growable_fifo_queue< s3_txport_event >::push, and s3_growable_fifo_queue< s3_txport_event >::size. |
Send comments to: s3fc@stonethree.com |
|