#include <thread_util.h>
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... |
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.
T | data type in FIFO |
|
\warn No implementation of the copy constructor. |
|
Build a FIFO of fixed size and alllocate the memory. The constructor is _not_ fully thread safe.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|