#include <SingleProducerConsumer.h>
Public Member Functions | |
SingleProducerConsumer () | |
Constructor. | |
~SingleProducerConsumer () | |
Destructor. | |
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 |
Private Attributes | |
volatile DataPlusPtr * | readAheadPointer |
volatile DataPlusPtr * | writeAheadPointer |
volatile DataPlusPtr * | readPointer |
volatile DataPlusPtr * | writePointer |
unsigned | readCount |
unsigned | writeCount |
Classes | |
struct | DataPlusPtr |
|
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
|
|
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() |
|
Returns if ReadUnlock was called before ReadLock
|
|
ReadLock must be immediately followed by ReadUnlock. These two functions must be called in the same thread.
|
|
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. |
|
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.
|
|
WriteLock must be immediately followed by WriteUnlock. These two functions must be called in the same thread.
|