| S3FC project page | S3FC home page |
#include <s3_spsc_fifo_queue.h>
Inheritance diagram for s3_spsc_fifo_queue:


Public Methods | |
| s3_spsc_fifo_queue (unsigned int n_buffer_size=5) | |
| Constructor for the FIFO queue. More... | |
| virtual | ~s3_spsc_fifo_queue () |
| Destructor for the FIFO queue. More... | |
| bool | empty () const |
| Indicate if the queue is empty or not. More... | |
| bool | full () const |
| Indicate if the queue is full or not. More... | |
| unsigned int | size () const |
| Returns the number of entries in the queue. More... | |
| T * | open_input () |
| This method determine if there is an open slot to fill and return a pointer to one if there is. More... | |
| T * | nbl_open_input () |
| Non-blocking open input. More... | |
| void | close_input (const T *t=0) |
| This method is called to signal that the producer has written all the data. More... | |
| T * | open_output () |
| This method determine if there is an open slot to receive data from, if there is a pointer to the data is returned. More... | |
| T * | nbl_open_output () |
| Non-blocking open output. More... | |
| void | close_output (const T *t=0) |
| This method is called to signal that the consumer has read all the data. More... | |
Protected Methods | |
| bool | crit_empty () const |
| bool | crit_full () const |
| T * | crit_open_input () |
| T * | crit_open_output () |
Private Attributes | |
| unsigned int | buffer_size |
| Internal variable that saves the buffer size. More... | |
| T * | buffer |
| Pointer to the start of the circular buffer. More... | |
| unsigned int | c_size |
| Internal variable that keeps track of the number of entries in the queue. More... | |
| unsigned int | input_index |
| Index pointing to the next open slot for input. More... | |
| unsigned int | output_index |
| Index pointing to the next available slot for output. More... | |
| pthread_mutex_t | access_lock_a |
| Our access locking mutex. More... | |
| pthread_mutex_t | access_lock_p |
| Our producer locking mutex. More... | |
| pthread_mutex_t | access_lock_c |
| Our consumer locking mutex. More... | |
| sem_t | sem_read |
| Semaphore that controls input access. More... | |
| sem_t | sem_write |
| Semaphore that controlls output access. More... | |
The FIFO is implemented using a circular array buffer.
Definition at line 49 of file s3_spsc_fifo_queue.h.
|
||||||||||
|
Constructor for the FIFO queue. The constructor preallocate the required memory for the queue.
Definition at line 109 of file s3_spsc_fifo_queue.h. References access_lock_a, access_lock_c, access_lock_p, buffer, buffer_size, c_size, input_index, output_index, sem_read, and sem_write. |
|
|||||||||
|
Destructor for the FIFO queue. It deallocate the buffer memory. Definition at line 132 of file s3_spsc_fifo_queue.h. References access_lock_a, access_lock_c, access_lock_p, buffer, sem_read, and sem_write. |
|
||||||||||
|
This method is called to signal that the producer has written all the data. The slot is now available for output. Implements s3_inplace_fifo_base. Definition at line 216 of file s3_spsc_fifo_queue.h. References access_lock_p, buffer_size, c_size, input_index, s3_subscribable_fifo::notify_consumers, and sem_read. |
|
||||||||||
|
This method is called to signal that the consumer has read all the data. The slot is now available for input again. Implements s3_inplace_fifo_base. Definition at line 265 of file s3_spsc_fifo_queue.h. References access_lock_c, buffer_size, c_size, s3_subscribable_fifo::notify_producers, output_index, and sem_write. |
|
|||||||||
|
Definition at line 77 of file s3_spsc_fifo_queue.h. References c_size. Referenced by empty, and nbl_open_output. |
|
|||||||||
|
Definition at line 82 of file s3_spsc_fifo_queue.h. References buffer_size, and c_size. Referenced by full, and nbl_open_input. |
|
|||||||||
|
Definition at line 87 of file s3_spsc_fifo_queue.h. References buffer, input_index, and sem_write. Referenced by nbl_open_input, and open_input. |
|
|||||||||
|
Definition at line 95 of file s3_spsc_fifo_queue.h. References buffer, output_index, and sem_read. Referenced by nbl_open_output, and open_output. |
|
|||||||||
|
Indicate if the queue is empty or not.
Implements s3_fifo_base. Definition at line 147 of file s3_spsc_fifo_queue.h. References access_lock_a, crit_empty, and NONCONST_MUTEXP. |
|
|||||||||
|
Indicate if the queue is full or not.
Implements s3_fifo_base. Definition at line 159 of file s3_spsc_fifo_queue.h. References access_lock_a, crit_full, and NONCONST_MUTEXP. |
|
|||||||||
|
Non-blocking open input.
Implements s3_inplace_fifo_base. Definition at line 196 of file s3_spsc_fifo_queue.h. References access_lock_p, crit_full, and crit_open_input. |
|
|||||||||
|
Non-blocking open output.
Implements s3_inplace_fifo_base. Definition at line 246 of file s3_spsc_fifo_queue.h. References access_lock_p, crit_empty, and crit_open_output. |
|
|||||||||
|
This method determine if there is an open slot to fill and return a pointer to one if there is. The method will block if the circular buffer is full.
Implements s3_inplace_fifo_base. Definition at line 185 of file s3_spsc_fifo_queue.h. References access_lock_p, and crit_open_input. |
|
|||||||||
|
This method determine if there is an open slot to receive data from, if there is a pointer to the data is returned. The method will block if the queue is empty.
Implements s3_inplace_fifo_base. Definition at line 235 of file s3_spsc_fifo_queue.h. References access_lock_c, and crit_open_output. |
|
|||||||||
|
Returns the number of entries in the queue.
Implements s3_fifo_base. Definition at line 171 of file s3_spsc_fifo_queue.h. References access_lock_a, c_size, and NONCONST_MUTEXP. |
|
|||||
|
Our access locking mutex.
Definition at line 66 of file s3_spsc_fifo_queue.h. Referenced by empty, full, s3_spsc_fifo_queue, size, and ~s3_spsc_fifo_queue. |
|
|||||
|
Our consumer locking mutex.
Definition at line 70 of file s3_spsc_fifo_queue.h. Referenced by close_output, open_output, s3_spsc_fifo_queue, and ~s3_spsc_fifo_queue. |
|
|||||
|
Our producer locking mutex.
Definition at line 68 of file s3_spsc_fifo_queue.h. Referenced by close_input, nbl_open_input, nbl_open_output, open_input, s3_spsc_fifo_queue, and ~s3_spsc_fifo_queue. |
|
|||||
|
Pointer to the start of the circular buffer.
Definition at line 55 of file s3_spsc_fifo_queue.h. Referenced by crit_open_input, crit_open_output, s3_spsc_fifo_queue, and ~s3_spsc_fifo_queue. |
|
|||||
|
Internal variable that saves the buffer size.
Definition at line 53 of file s3_spsc_fifo_queue.h. Referenced by close_input, close_output, crit_full, and s3_spsc_fifo_queue. |
|
|||||
|
Internal variable that keeps track of the number of entries in the queue.
Definition at line 60 of file s3_spsc_fifo_queue.h. Referenced by close_input, close_output, crit_empty, crit_full, s3_spsc_fifo_queue, and size. |
|
|||||
|
Index pointing to the next open slot for input.
Definition at line 62 of file s3_spsc_fifo_queue.h. Referenced by close_input, crit_open_input, and s3_spsc_fifo_queue. |
|
|||||
|
Index pointing to the next available slot for output.
Definition at line 64 of file s3_spsc_fifo_queue.h. Referenced by close_output, crit_open_output, and s3_spsc_fifo_queue. |
|
|||||
|
Semaphore that controls input access.
Definition at line 72 of file s3_spsc_fifo_queue.h. Referenced by close_input, crit_open_output, s3_spsc_fifo_queue, and ~s3_spsc_fifo_queue. |
|
|||||
|
Semaphore that controlls output access.
Definition at line 74 of file s3_spsc_fifo_queue.h. Referenced by close_output, crit_open_input, s3_spsc_fifo_queue, and ~s3_spsc_fifo_queue. |
| Send comments to: s3fc@stonethree.com |
|