Valkka  1.6.1
OpenSource Video Management
Public Member Functions | List of all members
SharedMemRingBuffer Class Reference
Inheritance diagram for SharedMemRingBuffer:
Inheritance graph
[legend]
Collaboration diagram for SharedMemRingBuffer:
Collaboration graph
[legend]

Public Member Functions

 SharedMemRingBuffer (const char *name, int n_cells, std::size_t n_bytes, int mstimeout=0, bool is_server=false)
 
virtual ~SharedMemRingBuffer ()
 Default destructor.
 
void serverPush (std::vector< uint8_t > &inp_payload)
 
bool serverPushPy (PyObject *po)
 Push a numpy array.
 
bool clientPull (int &index_out, int &size_out)
 
- Public Member Functions inherited from SharedMemRingBufferBase
 SharedMemRingBufferBase (const char *name, int n_cells, std::size_t n_bytes, int mstimeout=0, bool is_server=false)
 Default constructor. More...
 
virtual ~SharedMemRingBufferBase ()
 Default destructor.
 
int getValue ()
 Returns the current index (next to be read) of the shmem buffer.
 
bool getClientState ()
 Are the shmem segments available for client?
 
void serverPush (std::vector< uint8_t > &inp_payload, void *meta)
 Copies payload to ring buffer. More...
 
void serverUseFd (EventFd &event_fd)
 Activate the file descriptor api for usage with select and poll.
 
bool clientPull (int &index_out, void *meta)
 Returns the index of SharedMemoryRingBuffer::shmems that was just written. More...
 
bool clientPullThread (int &index_out, void *meta)
 multithreading version: releases GIL
 
PyObject * getBufferListPy ()
 
void clientUseFd (EventFd &event_fd)
 Activate the file descriptor api for usage with select and poll.
 

Additional Inherited Members

- Public Attributes inherited from SharedMemRingBufferBase
std::vector< SharedMemSegment * > shmems
 Shared memory segments - can be exposed as numpy arrays.
 
uint8_t ** cache
 One can expose a cache instead as numpy arrays - but this requires an additional copy step - enable with flag USE_SHMEM_CACHE.
 
- Protected Member Functions inherited from SharedMemRingBufferBase
void setFlag ()
 Server: call this to indicate a ring-buffer overflow.
 
bool flagIsSet ()
 Client: call this to see if there has been a ring-buffer overflow.
 
void clearFlag ()
 Client: call this after handling the ring-buffer overflow.
 
int getFlagValue ()
 Used by SharedMemoryRingBuffer::flagIsSet()
 
void zero ()
 Force reset. Semaphore value is set to 0.
 
void setEventFd ()
 Set event file descriptor.
 
void clearEventFd ()
 Clear event file descriptor.
 
- Protected Attributes inherited from SharedMemRingBufferBase
std::string name
 
int n_cells
 
int n_bytes
 Parameters defining the shmem ring buffer (number, size)
 
int mstimeout
 Semaphore timeout in milliseconds.
 
bool is_server
 Are we on the server side or not?
 
sem_t * sema
 
sem_t * flagsema
 Posix semaphore objects (semaphore counter, semaphore for the overflow flag)
 
std::string sema_name
 Name to identify the posix semaphore counter.
 
std::string flagsema_name
 Name to identify the posix semaphore used for the overflow flag.
 
int index
 The index of cell that has just been written. Remember: server and client see their own copies of this.
 
struct timespec ts
 Timespec for semaphore timeouts.
 
int fd
 A file descriptor for poll and select.
 

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