ucommon
Public Member Functions
ucommon::bufferof< T > Class Template Reference

A templated typed class for buffering of objects. More...

#include <containers.h>

Inheritance diagram for ucommon::bufferof< T >:
Inheritance graph
[legend]
Collaboration diagram for ucommon::bufferof< T >:
Collaboration graph
[legend]

Public Member Functions

const T & at (unsigned item)
 Examine past item in the buffer.
 
 bufferof (unsigned capacity)
 Create a buffer to hold a series of typed objects.
 
void copy (T *object)
 Copy the next typed object from the buffer.
 
T * get (void)
 Get the next typed object from the buffer.
 
T * get (timeout_t timeout)
 Get the next typed object from the buffer.
 
bool get (T *object, timeout_t timeout)
 Copy the next typed object from the buffer.
 
T * operator() (unsigned offset=0)
 
T & operator[] (unsigned item)
 Examine past item in the buffer.
 
void put (T *object)
 Put (copy) a typed object into the buffer.
 
bool put (T *object, timeout_t timeout)
 Put (copy) an object into the buffer.
 
- Public Member Functions inherited from ucommon::Buffer
unsigned count (void)
 Get the number of objects in the buffer currently.
 
 operator bool ()
 Test if there is data waiting in the buffer.
 
bool operator! ()
 Test if the buffer is empty.
 
unsigned size (void)
 Get the size of the buffer.
 

Additional Inherited Members

- Protected Member Functions inherited from ucommon::Buffer
 Buffer (size_t typesize, size_t count)
 Create a buffer to hold a series of objects.
 
void copy (void *data)
 Copy the next object from the buffer.
 
bool copy (void *data, timeout_t timeout)
 Copy the next object from the buffer.
 
void * get (timeout_t timeout)
 Get the next object from the buffer.
 
void * get (void)
 Get the next object from the buffer.
 
virtual void * invalid (void) const
 
void * peek (unsigned item)
 Peek at pending data in buffer.
 
void put (void *data)
 Put (copy) an object into the buffer.
 
bool put (void *data, timeout_t timeout)
 Put (copy) an object into the buffer.
 
void release (void)
 Release must be called when we get an object from the buffer.
 
virtual ~Buffer ()
 Deallocate buffer and unblock any waiting threads.
 
- Static Protected Member Functions inherited from ucommon::Conditional
static pthread_condattr_t * initializer (void)
 Support function for getting conditional attributes for realtime scheduling.
 
static void set (struct timespec *hires, timeout_t timeout)
 Convert a millisecond timeout into use for high resolution conditional timers.
 

Detailed Description

template<class T>
class ucommon::bufferof< T >

A templated typed class for buffering of objects.

This operates as a fifo buffer of typed objects which are physically copied into the buffer. The objects that are buffered are accessed from allocated buffer space. As designed this may be used with multiple producer threads and one consumer thread. To use multiple consumers, one can copy the typed object from the buffer through the get pointer and then call release. The copied object can then be used safely. This is what the copy method is used for.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 434 of file containers.h.

Constructor & Destructor Documentation

template<class T >
ucommon::bufferof< T >::bufferof ( unsigned  capacity)
inline

Create a buffer to hold a series of typed objects.

Parameters
countof typed objects in the buffer.

Definition at line 441 of file containers.h.

Member Function Documentation

template<class T >
const T& ucommon::bufferof< T >::at ( unsigned  item)
inline

Examine past item in the buffer.

This is a typecast of the peek operation.

Parameters
itemin buffer.
Returns
item pointer if valid or NULL.

Definition at line 500 of file containers.h.

template<class T >
void ucommon::bufferof< T >::copy ( T *  object)
inline

Copy the next typed object from the buffer.

This blocks until an object becomes available.

Parameters
objectpointer to copy typed object into.

Definition at line 482 of file containers.h.

Here is the call graph for this function:

template<class T >
T* ucommon::bufferof< T >::get ( void  )
inline

Get the next typed object from the buffer.

This blocks until an object becomes available.

Returns
pointer to next typed object from buffer.

Definition at line 449 of file containers.h.

template<class T >
T* ucommon::bufferof< T >::get ( timeout_t  timeout)
inline

Get the next typed object from the buffer.

Parameters
timeoutto wait when buffer is empty in milliseconds.
Returns
pointer to next typed object in the buffer or NULL if timed out.

Definition at line 457 of file containers.h.

template<class T >
bool ucommon::bufferof< T >::get ( T *  object,
timeout_t  timeout 
)
inline

Copy the next typed object from the buffer.

Parameters
objectpointer to copy typed object into.
timeoutto wait when buffer is empty in milliseconds.
Returns
true if object copied, or false if timed out.

Definition at line 491 of file containers.h.

Here is the call graph for this function:

template<class T >
T& ucommon::bufferof< T >::operator[] ( unsigned  item)
inline

Examine past item in the buffer.

This is a typecast of the peek operation.

Parameters
itemin buffer.
Returns
item pointer if valid or NULL.

Definition at line 509 of file containers.h.

template<class T >
void ucommon::bufferof< T >::put ( T *  object)
inline

Put (copy) a typed object into the buffer.

This blocks while the buffer is full.

Parameters
objectto copy into the buffer.

Definition at line 465 of file containers.h.

Here is the call graph for this function:

template<class T >
bool ucommon::bufferof< T >::put ( T *  object,
timeout_t  timeout 
)
inline

Put (copy) an object into the buffer.

Parameters
objectto copy into the buffer.
timeoutto wait if buffer is full.
Returns
true if copied, false if timed out while full.

Definition at line 474 of file containers.h.

Here is the call graph for this function:


The documentation for this class was generated from the following file: