ucc::bufferof< T > Class Template Reference

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

#include <thread.h>

Inheritance diagram for ucc::bufferof< T >:

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

Collaboration graph
[legend]

Public Member Functions

 bufferof (unsigned count)
 Create a buffer to hold a series of typed objects.
T * get (void)
 Get the next typed object from the buffer.
T * get (timeout_t timeout)
 Get the next typed object from 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.
void copy (T *object)
 Copy the next typed object from the buffer.
bool get (T *object, timeout_t timeout)
 Copy the next typed object from the buffer.

Detailed Description

template<class T>
class ucc::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@gnutelephony.org>

Definition at line 2226 of file thread.h.


Constructor & Destructor Documentation

template<class T >
ucc::bufferof< T >::bufferof ( unsigned  count  )  [inline]

Create a buffer to hold a series of typed objects.

Parameters:
count of typed objects in the buffer.

Definition at line 2233 of file thread.h.


Member Function Documentation

template<class T >
void ucc::bufferof< T >::copy ( T *  object  )  [inline]

Copy the next typed object from the buffer.

This blocks until an object becomes available.

Parameters:
object pointer to copy typed object into.

Definition at line 2274 of file thread.h.

Here is the call graph for this function:

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

Copy the next typed object from the buffer.

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

Definition at line 2283 of file thread.h.

Here is the call graph for this function:

template<class T >
T* ucc::bufferof< T >::get ( timeout_t  timeout  )  [inline]

Get the next typed object from the buffer.

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

Reimplemented from ucc::Buffer.

Definition at line 2249 of file thread.h.

template<class T >
T* ucc::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.

Reimplemented from ucc::Buffer.

Definition at line 2241 of file thread.h.

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

Put (copy) an object into the buffer.

Parameters:
object to copy into the buffer.
timeout to wait if buffer is full.
Returns:
true if copied, false if timed out while full.

Definition at line 2266 of file thread.h.

Here is the call graph for this function:

template<class T >
void ucc::bufferof< T >::put ( T *  object  )  [inline]

Put (copy) a typed object into the buffer.

This blocks while the buffer is full.

Parameters:
object to copy into the buffer.

Definition at line 2257 of file thread.h.

Here is the call graph for this function:


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

Generated on Wed May 13 09:18:36 2009 for UCommon by  doxygen 1.5.8