Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

thread::FiFo Class Template Reference

Threadsafe FIFO with fixed size. More...

#include <thread_util.h>

List of all members.

Public Methods

 ~FiFo ()
 Frees allocated memory, but it is _not_ fully thread safe.

 FiFo (const FiFo &)
 FiFo (size_t size)
 Build a FIFO of fixed size and alllocate the memory. More...

const T * Get_Start (bool block)
 Returns the pointer to the actual read position, but does not mark it as read. More...

void Get_End (bool _remove)
 Finish the reading process started with Get_Start(bool). More...

T * Put_Start (bool block)
 Returns the pointer to the actual write position, but does not mark it as written. More...

void Put_End (bool _remove)
 Finish the writing process started with Put_Start(bool). More...


Detailed Description

template<typename T>
class thread::FiFo< T >

Threadsafe FIFO with fixed size.

This is just the example of the pthread documentation written as templated class. Only the both ends of the FIFO are thread safe, i.e. you can read on an other thread as you are writing, but you cannot threadsafe read (write) on different threads in parallel.

Parameters:
T  data type in FIFO


Constructor & Destructor Documentation

template<typename T>
thread::FiFo< T >::FiFo const FiFo< T > &   
 

\warn No implementation of the copy constructor.

template<typename T>
thread::FiFo< T >::FiFo size_t    size
 

Build a FIFO of fixed size and alllocate the memory.

The constructor is _not_ fully thread safe.

Parameters:
size  Fixed size of the FIFO


Member Function Documentation

template<typename T>
const T* thread::FiFo< T >::Get_Start bool    block
 

Returns the pointer to the actual read position, but does not mark it as read.

You can only use the returned pointer between the Get_Start(bool) and Get_End(bool) calls, since only for this time the actual entry is locked. You should not call this within an other Get_Start(bool) ... Get_End(bool) block.

Parameters:
block  true: Wait until some input on the write end of the FIFO false: do not wait
Returns:
Pointer to actual FIFO entry. NULL if nonlocking waiting and no input on read end.

template<typename T>
void thread::FiFo< T >::Get_End bool    _remove
 

Finish the reading process started with Get_Start(bool).

This makes the pointer returned by Get_Start(bool) invalid and you can decide to either put back the entry to queue or remove it form queue.

Parameters:
_remove  true: remove the acutal entry from queue, false: do not remove it.

template<typename T>
T* thread::FiFo< T >::Put_Start bool    block
 

Returns the pointer to the actual write position, but does not mark it as written.

You can only use the returned pointer between the Put_Start(bool) and Put_End(bool) calls, since only for this time the actual entry is locked. You should not call this within an other Put_Start(bool) ... Put_End(bool) block.

Parameters:
block  true: Wait until there is space to write at the FIFO false: do not wait
Returns:
Pointer to actual FIFO entry. NULL if nonlocking waiting and the FIFO is full.

template<typename T>
void thread::FiFo< T >::Put_End bool    _remove
 

Finish the writing process started with Put_Start(bool).

This makes the pointer returned by Put_Start(bool) invalid and you can decide to either write or discard the entry.

Parameters:
_remove  true: write the actual entry, false: discard it


The documentation for this class was generated from the following file:
Generated on Sun Apr 14 17:37:03 2002 for libvtql by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002