SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | List of all members
DataStructures::SingleProducerConsumer< SingleProducerConsumerType > Class Template Reference

A single producer consumer implementation without critical sections. More...

`#include <slikenet/SingleProducerConsumer.h>`

Inheritance diagram for DataStructures::SingleProducerConsumer< SingleProducerConsumerType >:

## Public Member Functions

| SingleProducerConsumer ()
| ~SingleProducerConsumer ()
SingleProducerConsumerType * | WriteLock (void)
void | CancelWriteLock (SingleProducerConsumerType *cancelToLocation)
void | WriteUnlock (void)
| Call when you are done writing to a block of memory returned by WriteLock()
SingleProducerConsumerType * | ReadLock (void)
void | CancelReadLock (SingleProducerConsumerType *cancelToLocation)
| param[in] Which ReadLock() to cancel.
void | ReadUnlock (void)
void | Clear (void)
| Clear is not thread-safe and none of the lock or unlock functions should be called while it is running.
int | Size (void) const
bool | CheckReadUnlockOrder (const SingleProducerConsumerType *data) const
bool | ReadIsLocked (void) const

## Detailed Description

### template<class SingleProducerConsumerType>
class DataStructures::SingleProducerConsumer< SingleProducerConsumerType >

A single producer consumer implementation without critical sections.

Definition at line 38 of file SingleProducerConsumer.h.

## Constructor & Destructor Documentation

template<class SingleProducerConsumerType >

DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::SingleProducerConsumer | ( |  | ) |

Definition at line 105 of file SingleProducerConsumer.h.

References _FILE_AND_LINE_, MINIMUM_LIST_SIZE, and RakAssert.

template<class SingleProducerConsumerType >

DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::~SingleProducerConsumer | ( |  | ) |

Definition at line 128 of file SingleProducerConsumer.h.

References _FILE_AND_LINE_, and SLNet::OP_DELETE().

## Member Function Documentation

template<class SingleProducerConsumerType>

void DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::CancelReadLock | ( | SingleProducerConsumerType * | cancelToLocation | ) |

param[in] Which ReadLock() to cancel.

Definition at line 198 of file SingleProducerConsumer.h.

References RakAssert.

template<class SingleProducerConsumerType>

void DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::CancelWriteLock | ( | SingleProducerConsumerType * | cancelToLocation | ) |

Call if you don't want to write to a block of data from WriteLock() after all. Cancelling locks cancels all locks back up to the data passed. So if you lock twice and cancel using the first lock, the second lock is ignored

Parameters

  [in] | cancelToLocation | Which WriteLock() to cancel.

Definition at line 161 of file SingleProducerConsumer.h.

template<class SingleProducerConsumerType>

bool DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::CheckReadUnlockOrder | ( | const SingleProducerConsumerType * | data | ) | const

Make sure that the pointer we done reading for the call to ReadUnlock is the right pointer. param[in] A previous pointer returned by ReadLock()

Definition at line 259 of file SingleProducerConsumer.h.

template<class SingleProducerConsumerType >

void DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::Clear | ( | void |  | ) |

Clear is not thread-safe and none of the lock or unlock functions should be called while it is running.

Definition at line 221 of file SingleProducerConsumer.h.

References _FILE_AND_LINE_, MINIMUM_LIST_SIZE, SLNet::OP_DELETE(), and RakAssert.

template<class SingleProducerConsumerType >

bool DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::ReadIsLocked | ( | void |  | ) | const

Returns if ReadUnlock was called before ReadLock

Returns
  If the read is locked

Definition at line 266 of file SingleProducerConsumer.h.

template<class SingleProducerConsumerType >

SingleProducerConsumerType * DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::ReadLock | ( | void |  | ) |

ReadLock must be immediately followed by ReadUnlock. These two functions must be called in the same thread.

Return values

  0 | No data is availble to read
  Non-zero | The data previously written to, in another thread, by WriteLock followed by WriteUnlock.

Definition at line 183 of file SingleProducerConsumer.h.

template<class SingleProducerConsumerType >

void DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::ReadUnlock | ( | void |  | ) |

Signals that we are done reading the the data from the least recent call of ReadLock. At this point that pointer is no longer valid, and should no longer be read.

Definition at line 207 of file SingleProducerConsumer.h.

References RakAssert.

template<class SingleProducerConsumerType >

int DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::Size | ( | void |  | ) | const

This function will estimate how many elements are waiting to be read. It's threadsafe enough that the value returned is stable, but not threadsafe enough to give accurate results.

Returns
  An ESTIMATE of how many data elements are waiting to be read

Definition at line 253 of file SingleProducerConsumer.h.

template<class SingleProducerConsumerType >

SingleProducerConsumerType * DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::WriteLock | ( | void |  | ) |

WriteLock must be immediately followed by WriteUnlock. These two functions must be called in the same thread.

Returns
  A pointer to a block of data you can write to.

Definition at line 142 of file SingleProducerConsumer.h.

References _FILE_AND_LINE_, and RakAssert.

template<class SingleProducerConsumerType >

void DataStructures::SingleProducerConsumer< SingleProducerConsumerType >::WriteUnlock | ( | void |  | ) |

Call when you are done writing to a block of memory returned by WriteLock()

Definition at line 167 of file SingleProducerConsumer.h.

References RakAssert.

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

- Source/include/slikenet/SingleProducerConsumer.h