SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
sutil::CSharedMemory< MemType, SignalType > Class Template Reference

#include <CSharedMemory.hpp>

Public Member Functions

 CSharedMemory (const key_t &arg_shmem_key, const SignalType &arg_term_cond)
 
bool shmCreate ()
 
bool shmRead ()
 
bool shmAlive ()
 
bool shmCheckDetach ()
 
bool shmDetach ()
 

Public Attributes

MemType * data_
 
SignalType * data_signal_
 
SignalType data_terminate_
 

Private Attributes

int shmem_id_
 
key_t key_
 
bool has_been_init_
 

Detailed Description

template<typename MemType, typename SignalType>
class sutil::CSharedMemory< MemType, SignalType >

This class implements a shared memory setup for client-server processes to communicate "on the same computer".

For this to work, MemType must be a data structure with a fixed type. And the client and server must share the same shared memory key code.

The signal type is usually a fast (atomic) data type like atomic_t in <asm/atomic.h> on Linux.

Functions that help you use the shared memory: Server : Create : shmCreate() Use : *shmem.data_ Signal : *shmem.data_signal_ Close : shmCheckDetach()

Client : Create : shmRead() Use : *shmem.data_ Signal : *shmem.data_signal_ Close : shmDetach()

Member Function Documentation

template<typename MemType , typename SignalType >
bool sutil::CSharedMemory< MemType, SignalType >::shmAlive ( )
inline

Terminates if *data_signal_ is set to data_terminate_

template<typename MemType , typename SignalType >
bool sutil::CSharedMemory< MemType, SignalType >::shmCheckDetach ( )
inline

Terminates if *data_signal_ is set to data_terminate_

template<typename MemType , typename SignalType >
bool sutil::CSharedMemory< MemType, SignalType >::shmCreate ( )
inline

A shared memory server creates the shared memory

template<typename MemType , typename SignalType >
bool sutil::CSharedMemory< MemType, SignalType >::shmDetach ( )
inline

Terminates the shared memory

template<typename MemType , typename SignalType >
bool sutil::CSharedMemory< MemType, SignalType >::shmRead ( )
inline

A shared memory client reads the shared memory

Member Data Documentation

template<typename MemType , typename SignalType >
MemType* sutil::CSharedMemory< MemType, SignalType >::data_

The data type

template<typename MemType , typename SignalType >
SignalType* sutil::CSharedMemory< MemType, SignalType >::data_signal_

The signal data type

template<typename MemType , typename SignalType >
SignalType sutil::CSharedMemory< MemType, SignalType >::data_terminate_

The signal termination condition


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