S3FC project page | S3FC home page |
#include <s3_fifo_queue.h>
Inheritance diagram for s3_fifo_queue:
Public Methods | |
s3_fifo_queue (unsigned int n_num_slots) | |
Construct a FIFO, specifying the size. More... | |
virtual | ~s3_fifo_queue () |
Destructor. More... | |
bool | empty () const |
Check and return whether this queue is empty. More... | |
bool | full () const |
Check and return whether this queue is full. More... | |
unsigned int | size () const |
Return number of elements in queue. More... | |
T * | open_input () |
Regular open input. More... | |
T * | nbl_open_input () |
Non-blocking open input. More... | |
void | close_input (const T *ptr) |
Release a previously-acquired production slot. More... | |
T * | open_output () |
Regular open output. More... | |
T * | nbl_open_output () |
Non-blocking open output. More... | |
void | close_output (const T *ptr) |
Release a previously-acquired consumption slot. More... | |
void | show_status (const char *str=0, int slot=-1) const |
Shows status of a fifo queue. More... | |
unsigned int | get_capacity (void) const |
Return the total number of slots in the queue. More... | |
Protected Methods | |
T * | open_input (bool blocking) |
Acquire the candidate production slot. More... | |
T * | open_output (bool blocking) |
Acquire the candidate consumption slot. More... | |
Protected Attributes | |
unsigned int | num_slots |
Total number of slots. More... | |
pthread_mutex_t | state_lock |
Mutex protecting our p_rdy and c_rdy variables. More... | |
bool * | p_rdy |
Flags indicating whether a slot is ready for production. More... | |
bool * | c_rdy |
Flags indicating whether a slot is ready for consumption. More... | |
pthread_cond_t | p_rdy_changed |
Condition varible that gets set when any p_rdy flag changes to true. More... | |
pthread_cond_t | c_rdy_changed |
Condition variable that gets set when any c_rdy flag changes to true. More... | |
unsigned int | p_candidate |
Index of the slot that is to be used next for production. More... | |
unsigned int | c_candidate |
Index of the slot that is to be used next for output. More... | |
T * | slots |
Buffer holding num_slots data slots. More... |
An arbitrary number (limited by the size and content) of producers can gain exclusive write access to buffer slots at the tail of the queue, and an arbitrary number of consumers can gain exclusive read access to buffer slots at the head of the queue. Templated on a single type, T
, indicating the type of data stored in the queue.
Definition at line 61 of file s3_fifo_queue.h.
|
Construct a FIFO, specifying the size.
Definition at line 109 of file s3_fifo_queue.h. |
|
Destructor. Clean all the thread variables. Definition at line 132 of file s3_fifo_queue.h. |
|
Release a previously-acquired production slot.
Implements s3_inplace_fifo_base. Definition at line 275 of file s3_fifo_queue.h. |
|
Release a previously-acquired consumption slot.
Implements s3_inplace_fifo_base. Definition at line 380 of file s3_fifo_queue.h. |
|
Check and return whether this queue is empty. It is considered empty when the next candidate consumption slot is unavailable. Implements s3_fifo_base. Definition at line 146 of file s3_fifo_queue.h. Referenced by s3_post_office::main_loop. |
|
Check and return whether this queue is full. It is considered full when the next candidate production slot is unavailable. Implements s3_fifo_base. Definition at line 159 of file s3_fifo_queue.h. |
|
Return the total number of slots in the queue.
Definition at line 430 of file s3_fifo_queue.h. |
|
Non-blocking open input.
Implements s3_inplace_fifo_base. Definition at line 260 of file s3_fifo_queue.h. |
|
Non-blocking open output.
Implements s3_inplace_fifo_base. Definition at line 365 of file s3_fifo_queue.h. |
|
Regular open input.
Implements s3_inplace_fifo_base. Definition at line 253 of file s3_fifo_queue.h. Referenced by s3_fifo_queue< s3_txport_data< s3_message > >::nbl_open_input, and s3_fifo_queue< s3_txport_data< s3_message > >::open_input. |
|
Acquire the candidate production slot.
The candidate slot is the next available slot in the queue, so when a producer calls the
If the candidate slot is immediately available, or becomes available while a caller is waiting, a pointer to the slot element is returned. This pointer should be passed to
Definition at line 213 of file s3_fifo_queue.h. |
|
Regular open output.
Implements s3_inplace_fifo_base. Definition at line 358 of file s3_fifo_queue.h. Referenced by s3_fifo_queue< s3_txport_data< s3_message > >::nbl_open_output, and s3_fifo_queue< s3_txport_data< s3_message > >::open_output. |
|
Acquire the candidate consumption slot.
The candidate slot is the next available slot in the queue, so when a consumer calls the
A pointer to the slot element is returned and should be passed to
Definition at line 316 of file s3_fifo_queue.h. |
|
Shows status of a fifo queue. Each of the slots in a queue is checked and five possible values are printed. For a producer slot, 'P' means that a slot is ready for production and 'p' means a slot is not ready for production. For a comsumer slot, 'C' means ready for consumption and 'c' means not ready for comsumption. Look at the c_rdy and p_rdy member functions too. If it prints an '!' it has another unknown weird state. Definition at line 404 of file s3_fifo_queue.h. Referenced by s3_fifo_queue< s3_txport_data< s3_message > >::close_input, s3_fifo_queue< s3_txport_data< s3_message > >::close_output, s3_fifo_queue< s3_txport_data< s3_message > >::open_input, and s3_fifo_queue< s3_txport_data< s3_message > >::open_output. |
|
Return number of elements in queue. A count of the number of consumable slots is returned.
Implements s3_fifo_base. Definition at line 172 of file s3_fifo_queue.h. |
|
Index of the slot that is to be used next for output.
Definition at line 99 of file s3_fifo_queue.h. Referenced by s3_fifo_queue< s3_txport_data< s3_message > >::empty, s3_fifo_queue< s3_txport_data< s3_message > >::open_output, s3_fifo_queue< s3_txport_data< s3_message > >::s3_fifo_queue, and s3_fifo_queue< s3_txport_data< s3_message > >::show_status. |
|
Flags indicating whether a slot is ready for consumption. Each flag corresponds to a single slot. For true it is ready. Definition at line 81 of file s3_fifo_queue.h. Referenced by s3_fifo_queue< s3_txport_data< s3_message > >::close_input, s3_fifo_queue< s3_txport_data< s3_message > >::close_output, s3_fifo_queue< s3_txport_data< s3_message > >::empty, s3_fifo_queue< s3_txport_data< s3_message > >::open_output, s3_fifo_queue< s3_txport_data< s3_message > >::s3_fifo_queue, s3_fifo_queue< s3_txport_data< s3_message > >::show_status, s3_fifo_queue< s3_txport_data< s3_message > >::size, and s3_fifo_queue< s3_txport_data< s3_message > >::~s3_fifo_queue. |
|
Condition variable that gets set when any
Definition at line 91 of file s3_fifo_queue.h. Referenced by s3_fifo_queue< s3_txport_data< s3_message > >::close_input, s3_fifo_queue< s3_txport_data< s3_message > >::open_output, s3_fifo_queue< s3_txport_data< s3_message > >::s3_fifo_queue, and s3_fifo_queue< s3_txport_data< s3_message > >::~s3_fifo_queue. |
|
|
Index of the slot that is to be used next for production.
Definition at line 95 of file s3_fifo_queue.h. Referenced by s3_fifo_queue< s3_txport_data< s3_message > >::full, s3_fifo_queue< s3_txport_data< s3_message > >::open_input, s3_fifo_queue< s3_txport_data< s3_message > >::s3_fifo_queue, and s3_fifo_queue< s3_txport_data< s3_message > >::show_status. |
|
Flags indicating whether a slot is ready for production. Each flag corresponds to a single slot. For true, it is ready. Definition at line 76 of file s3_fifo_queue.h. Referenced by s3_fifo_queue< s3_txport_data< s3_message > >::close_input, s3_fifo_queue< s3_txport_data< s3_message > >::close_output, s3_fifo_queue< s3_txport_data< s3_message > >::full, s3_fifo_queue< s3_txport_data< s3_message > >::open_input, s3_fifo_queue< s3_txport_data< s3_message > >::s3_fifo_queue, s3_fifo_queue< s3_txport_data< s3_message > >::show_status, and s3_fifo_queue< s3_txport_data< s3_message > >::~s3_fifo_queue. |
|
Condition varible that gets set when any
Definition at line 86 of file s3_fifo_queue.h. Referenced by s3_fifo_queue< s3_txport_data< s3_message > >::close_output, s3_fifo_queue< s3_txport_data< s3_message > >::open_input, s3_fifo_queue< s3_txport_data< s3_message > >::s3_fifo_queue, and s3_fifo_queue< s3_txport_data< s3_message > >::~s3_fifo_queue. |
|
|
Send comments to: s3fc@stonethree.com |
|