A ring buffer for interprocess communication, with managed occupancy. More...
#include <osvr/Common/IPCRingBuffer.h>
Classes | |
class | BufferReadProxy |
A class providing access to an entry in the ring buffer, holding a sharable mutex lock preventing it from being overwritten while this object is in scope. More... | |
class | BufferWriteProxy |
A class providing write access to the next available element in the ring buffer, owning the appropriate mutex locks and providing access to the sequence number. More... | |
class | Options |
Public Types | |
typedef uint8_t | BackendType |
typedef uint16_t | alignment_type |
typedef uint16_t | entry_count_type |
typedef uint32_t | entry_size_type |
typedef uint32_t | abi_level_type |
typedef uint32_t | sequence_type |
The sequence number is automatically incremented with each "put" into the buffer. Note that, as an unsigned integer, it does have (and uses) well-defined overflow semantics. | |
typedef uint8_t | value_type |
typedef value_type * | pointer_type |
typedef value_type const * | pointer_to_const_type |
typedef shared_ptr< value_type > | smart_pointer_type |
Public Member Functions | |
BackendType | getBackend () const |
Returns an integer identifying the IPC backend used. | |
std::string const & | getName () const |
Returns the name string used to create or find this ring buffer. | |
uint32_t | getEntrySize () const |
Returns the size of each individual buffer entry, in bytes. | |
uint16_t | getEntries () const |
Returns the total capacity, in number of buffer entries, of this ring buffer. | |
sequence_type | put (pointer_to_const_type data, size_t len) |
Puts the data in the next element in the buffer (using memcpy). Buffer sizes are not checked! More... | |
BufferWriteProxy | put () |
Gets a proxy object for putting data in the next element in the buffer. You're responsible for doing the copying and, once you let the returned object exit scope, the notification (possibly with sequence number) | |
BufferReadProxy | get (sequence_type num) |
Gets access to an element in the buffer by sequence number: returns a proxy object that behaves mostly like a smart pointer. | |
BufferReadProxy | getLatest () |
Gets access to the most recent element in the buffer: returns a proxy object that behaves mostly like a smart pointer, and that also contains the associated sequence number. | |
~IPCRingBuffer () | |
Destructor. | |
Static Public Member Functions | |
static abi_level_type | getABILevel () |
Gets an integer representing a unique arrangement of the internal shared memory layout, such that if two processes try to communicate with different ABI levels, they will (likely) not succeed and thus should not try. | |
static IPCRingBufferPtr | create (Options const &opts) |
Named constructor, for use by server processes: creates a shared memory ring buffer given the options structure. More... | |
static IPCRingBufferPtr | find (Options const &opts) |
Named constructor, for use by client processes: accesses an IPC ring buffer using the options structure. Only the name field is used from the options. More... | |
A ring buffer for interprocess communication, with managed occupancy.
Each element in the ring buffer (that is, the contained buffers) is aligned to the given power of 2 alignment.
Designed to provide large-format data transfer in single-producer, roughly broadcast model, with an outside channel for communicating the segment name and signalling new data, and no guarantee that the data you were notified about won't be overwritten - just that if you're currently accessing data, we won't overwrite that.
Definition at line 65 of file IPCRingBuffer.h.
|
static |
Named constructor, for use by server processes: creates a shared memory ring buffer given the options structure.
If the returned pointer is not valid, the named segment could not be created for some reason.
|
static |
Named constructor, for use by client processes: accesses an IPC ring buffer using the options structure. Only the name field is used from the options.
If the returned pointer is not valid, the named buffer could not be found.
sequence_type osvr::common::IPCRingBuffer::put | ( | pointer_to_const_type | data, |
size_t | len | ||
) |