|
StuBS
|
The class BBuffer implements a bounded buffer, that is a circular buffer with a fixed capacity. More...
#include <object/bbuffer.h>
Public Member Functions | |
| BBuffer () | |
| Constructor that initialized an empty buffer. | |
| bool | produce (T val) |
| Add an element to the buffer. | |
| bool | consume (T &val) |
| Remove an element from the buffer. | |
Private Member Functions | |
| BBuffer (const BBuffer &)=delete | |
| BBuffer & | operator= (const BBuffer &)=delete |
Private Attributes | |
| T | data [CAP] |
| volatile unsigned | in |
| volatile unsigned | out |
The class BBuffer implements a bounded buffer, that is a circular buffer with a fixed capacity.
| T | the type of data to be stored |
| CAP | the buffers capacity (must be greater than 1) |
Constructor that initialized an empty buffer.
Add an element to the buffer.
| val | The element to be added. |
false if the buffer is full and no element can be added; true otherwise. Remove an element from the buffer.
| val | Output parameter that receives the next element. If there is (currently) no next element, val will not be modified. |
false if the buffer was empty; true if the buffer was not empty and an element was written to val.