SST  11.0.0
StructuralSimulationToolkit
SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType > Class Template Reference

This class defines a shared-memory region between a master process and one or more child processes Region has three data structures: More...

#include <tunneldef.h>

Public Member Functions

 TunnelDef (size_t numBuffers, size_t bufferSize, uint32_t expectedChildren)
 Create a new tunnel. More...
 
 TunnelDef (void *sPtr)
 Access an existing tunnel Child creates the TunnelDef, reads the shmSize, and then resizes its map accordingly. More...
 
uint32_t initialize (void *sPtr)
 Finish setting up a tunnel once the manager knows the correct size of the tunnel and has mmap'd a large enough region for it. More...
 
virtual ~TunnelDef ()
 Destructor.
 
void shutdown ()
 Clean up a region.
 
size_t getTunnelSize ()
 return size of tunnel
 
ShareDataType * getSharedData ()
 return a pointer to the ShareDataType region
 
void writeMessage (size_t buffer, const MsgType &command)
 Write data to buffer, blocks until space is available. More...
 
MsgType readMessage (size_t buffer)
 Read data from buffer, blocks until message received. More...
 
bool readMessageNB (size_t buffer, MsgType *result)
 Read data from buffer, non-blocking. More...
 
void clearBuffer (size_t buffer)
 Empty the messages in a buffer. More...
 
bool isMaster ()
 return whether this is a master-side tunnel or a child
 

Protected Member Functions

size_t getNumBuffers ()
 Return the number of buffers.
 

Protected Attributes

ShareDataType * sharedData
 Pointer to the Shared Data Region.
 

Detailed Description

template<typename ShareDataType, typename MsgType>
class SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType >

This class defines a shared-memory region between a master process and one or more child processes Region has three data structures:

  • internal bookkeeping (InternalSharedData),
  • user defined shared data (ShareDataType)
  • multiple circular-buffer queues with entries of type MsgType
Template Parameters
ShareDataTypeType to put in the shared data region
MsgTypeType of messages being sent in the circular buffers

Constructor & Destructor Documentation

template<typename ShareDataType , typename MsgType >
SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType >::TunnelDef ( size_t  numBuffers,
size_t  bufferSize,
uint32_t  expectedChildren 
)
inline

Create a new tunnel.

Parameters
numBuffersNumber of buffers for which we should tunnel
bufferSizeHow large each buffer should be
expectedChildrenNumber of child processes that will connect to this tunnel
template<typename ShareDataType , typename MsgType >
SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType >::TunnelDef ( void *  sPtr)
inline

Access an existing tunnel Child creates the TunnelDef, reads the shmSize, and then resizes its map accordingly.

Parameters
sPtrLocation of shared memory region

Member Function Documentation

template<typename ShareDataType , typename MsgType >
void SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType >::clearBuffer ( size_t  buffer)
inline

Empty the messages in a buffer.

Parameters
bufferwhich buffer to empty
template<typename ShareDataType , typename MsgType >
uint32_t SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType >::initialize ( void *  sPtr)
inline

Finish setting up a tunnel once the manager knows the correct size of the tunnel and has mmap'd a large enough region for it.

Parameters
sPtrLocation of shared memory region returns number of children left to attach

References SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType >::sharedData.

template<typename ShareDataType , typename MsgType >
MsgType SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType >::readMessage ( size_t  buffer)
inline

Read data from buffer, blocks until message received.

Parameters
bufferwhich buffer to read from return the message
template<typename ShareDataType , typename MsgType >
bool SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType >::readMessageNB ( size_t  buffer,
MsgType *  result 
)
inline

Read data from buffer, non-blocking.

Parameters
bufferwhich buffer to read from
resultpointer to return read message at return whether a message was read
template<typename ShareDataType , typename MsgType >
void SST::Core::Interprocess::TunnelDef< ShareDataType, MsgType >::writeMessage ( size_t  buffer,
const MsgType &  command 
)
inline

Write data to buffer, blocks until space is available.

Parameters
bufferwhich buffer index to write to
commandmessage to write to buffer

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