gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
BlockBuffer Class Reference

#include <BlockBuffer.H>

Inheritance diagram for BlockBuffer:
[legend]
Collaboration diagram for BlockBuffer:
[legend]

Public Member Functions

 BlockBuffer (int count)
 
 BlockBuffer (void)
 Constructor - creates BLOCK_BUFFER_DEFAULT_COUNT buffers. More...
 
Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > * getEmptyBuffer (void)
 
Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > * getFullBuffer (void)
 
void putFullBuffer (Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > *fb)
 
void putEmptyBuffer (Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > *eb)
 
int getBufferCount ()
 
void resizeBuffers (int rows, int cols)
 
void resize (int count)
 

Private Member Functions

void init (int count)
 

Private Attributes

std::vector< Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > > buffers
 The vector of buffers. More...
 
std::queue< Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > * > emptyBuffers
 The empty buffer queue. More...
 
std::queue< Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > * > fullBuffers
 The full buffer queue. More...
 
Mutex fullBufferMutex
 Used for. More...
 
Mutex emptyBufferMutex
 Used for. More...
 

Detailed Description

Class to manage used and unused buffers for double or more buffering. Uses mutexes so this class is thread safe. All buffers start on the emptyBuffers queue.

Examples:
BlockBufferTest.C.

Definition at line 34 of file BlockBuffer.H.

Constructor & Destructor Documentation

◆ BlockBuffer() [1/2]

BlockBuffer::BlockBuffer ( int  count)
inline

Constructor

Parameters
countThe number of buffers to create.

Definition at line 51 of file BlockBuffer.H.

Here is the call graph for this function:

◆ BlockBuffer() [2/2]

BlockBuffer::BlockBuffer ( void  )
inline

Constructor - creates BLOCK_BUFFER_DEFAULT_COUNT buffers.

Definition at line 56 of file BlockBuffer.H.

Here is the call graph for this function:

Member Function Documentation

◆ getBufferCount()

int BlockBuffer::getBufferCount ( )
inline

Find the number of buffers available in total.

Returns
the total buffer count.

Definition at line 111 of file BlockBuffer.H.

◆ getEmptyBuffer()

Eigen::Array<unsigned short, Eigen::Dynamic, Eigen::Dynamic>* BlockBuffer::getEmptyBuffer ( void  )
inline

Pop the next empty buffer off the empty queue. The returned buffer pointer is no longer held by the BlockBuffer::emptyBuffers nor BlockBuffer::fullBuffers and must be put back onto the empty or full buffers after use.

Returns
An empty buffer for use, if none are available the NULL.
Examples:
BlockBufferTest.C.

Definition at line 64 of file BlockBuffer.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFullBuffer()

Eigen::Array<unsigned short, Eigen::Dynamic, Eigen::Dynamic>* BlockBuffer::getFullBuffer ( void  )
inline

Pop the next full buffer off the full queue. The returned buffer pointer is no longer held by the BlockBuffer::fullBuffers nor BlockBuffer::emptyBuffers and must be put back onto the empty or full buffers after use.

Returns
A full buffer for use, if none are available the NULL.
Examples:
BlockBufferTest.C, and IIOQueueTest.C.

Definition at line 79 of file BlockBuffer.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

void BlockBuffer::init ( int  count)
inlineprivate

Definition at line 42 of file BlockBuffer.H.

Here is the caller graph for this function:

◆ putEmptyBuffer()

void BlockBuffer::putEmptyBuffer ( Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > *  eb)
inline

Push an empty buffer to the empty queue.

Parameters
fbThe full buffer to add to the full queue.
Examples:
BlockBufferTest.C, and IIOQueueTest.C.

Definition at line 102 of file BlockBuffer.H.

Here is the call graph for this function:

◆ putFullBuffer()

void BlockBuffer::putFullBuffer ( Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > *  fb)
inline

Push a full buffer to the full queue.

Parameters
fbThe full buffer to add to the full queue.
Examples:
BlockBufferTest.C.

Definition at line 93 of file BlockBuffer.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize()

void BlockBuffer::resize ( int  count)
inline

Resise the number of buffers contained. Each buffer is resized to the current buffer row/col sizes. All buffers are created and the emptyBuffers queue contains them. The fullBuffers queue is empty. Note: This should not be run whilst in operation. Ensure no other threads are accessing this class.

Parameters
countThe number of buffers to create.
Examples:
BlockBufferTest.C.

Definition at line 133 of file BlockBuffer.H.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resizeBuffers()

void BlockBuffer::resizeBuffers ( int  rows,
int  cols 
)
inline

resize all of the buffers

Parameters
rowsThe number of rows to create in each buffer.
colsThe number of cols to create in each buffer.
Examples:
BlockBufferTest.C.

Definition at line 119 of file BlockBuffer.H.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ buffers

std::vector<Eigen::Array<unsigned short, Eigen::Dynamic, Eigen::Dynamic> > BlockBuffer::buffers
private

The vector of buffers.

Definition at line 35 of file BlockBuffer.H.

◆ emptyBufferMutex

Mutex BlockBuffer::emptyBufferMutex
private

Used for.

Definition at line 40 of file BlockBuffer.H.

◆ emptyBuffers

std::queue<Eigen::Array<unsigned short, Eigen::Dynamic, Eigen::Dynamic> *> BlockBuffer::emptyBuffers
private

The empty buffer queue.

Definition at line 36 of file BlockBuffer.H.

◆ fullBufferMutex

Mutex BlockBuffer::fullBufferMutex
private

Used for.

Definition at line 39 of file BlockBuffer.H.

◆ fullBuffers

std::queue<Eigen::Array<unsigned short, Eigen::Dynamic, Eigen::Dynamic> *> BlockBuffer::fullBuffers
private

The full buffer queue.

Definition at line 37 of file BlockBuffer.H.


The documentation for this class was generated from the following file:
gtkIOStream: BlockBuffer Class Reference
GTK+ IOStream  Beta