template<class BUFFER> class OEProtectedBuffer
Thread-safe first-in-first-out (FIFO) queue that can have multiple producers and consumers. Meant to wrap around either a OEBoundedBuffer or OEUnboundedBuffer object to provide thread-safe access to those buffers. The OEBoundedBuffer queue should be used to control memory consumption, as the OEProtectedBuffer::Put operation will block, allowing the queue to empty first. The OEUnboundedBuffer queue will continue to consume memory with every OEProtectedBuffer::Put operation.
OEProtectedBuffer(oesize_t maxsize) OEProtectedBuffer(oesize_t maxsize, oesize_t threshold)
Constructs a new BUFFER, passing maxsize to the child buffer implementation. The threshold argument is a performance tuning parameter that determines how often OECondition::Broadcast is called. Broadcasting to other queue users too often can have negative performance implications as threads can be woken when there is not enough work in the queue to fill up their time quantum. Too infrequently means threads are left idle too long before being awoken with new to perform. The default threshold is half of maxsize.
Return the next item from the queue in a thread-safe manner.
The value used to signal termination to the queue. Calling OEProtectedBuffer::Put with the value returned by the Null method signals that the queue is ‘done’ and should not accept anymore data. Subsequent OEProtectedBuffer::Put operations will fail and return false. OEProtectedBuffer::Get will continue to return data until the queue is empty, and then start returning the result of the Null method as well. Note, this method returns the default constructed value for the value_type being stored in the queue, this is typically 0 or NULL for integral or pointer types respectively.
Returns the item that will be returned by the next call to OEProtectedBuffer::Get, but does not remove it from the buffer.
bool Put(value_type obj)
Place an item into the queue in a thread-safe manner.