HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SYS_SharedMemory Class Reference

#include <SYS_SharedMemory.h>

Public Member Functions

 SYS_SharedMemory (exint size=0)
 
 SYS_SharedMemory (exint size, const char *id)
 
 SYS_SharedMemory (const char *id, bool read_only=true)
 
 ~SYS_SharedMemory ()
 
 SYS_SharedMemory (const SYS_SharedMemory &)=delete
 
SYS_SharedMemoryoperator= (const SYS_SharedMemory &)=delete
 
bool reset (exint size, const char *id=nullptr)
 
const char * id () const
 
exint size () const
 Returns the size of the shared memory, in bytes. More...
 
bool readOnly () const
 Returns true if this shared memory is read-only. More...
 
int64 getMemoryUsage (bool inclusive) const
 
bool isValid () const
 

Static Public Member Functions

static void setTempDir (const char *path)
 

Friends

class SYS_SharedMemoryView
 

Detailed Description

Creates a read-only shared memory object, that accesses an existing shared memory buffer, using a unique identifier.

Definition at line 26 of file SYS_SharedMemory.h.

Constructor & Destructor Documentation

SYS_SharedMemory::SYS_SharedMemory ( exint  size = 0)

Create a new shared memory block of a given size. This constructor can fail, so you must use isValid to check for validity.

SYS_SharedMemory::SYS_SharedMemory ( exint  size,
const char *  id 
)

Create a new shared memory block with the given name and size. This constructor can fail, so you must use isValid to check for validity.

SYS_SharedMemory::SYS_SharedMemory ( const char *  id,
bool  read_only = true 
)

Open an existing shared memory block through the given identifier. This constructor can fail, so you must use isValid to check for validity.

SYS_SharedMemory::~SYS_SharedMemory ( )
SYS_SharedMemory::SYS_SharedMemory ( const SYS_SharedMemory )
delete

Member Function Documentation

int64 SYS_SharedMemory::getMemoryUsage ( bool  inclusive) const

Returns an approximation of the memory used by these structures, NOT the shared memory itself.

const char* SYS_SharedMemory::id ( ) const

Returns the identifier of the shared memory segment, such that it can be opened from another process. The pointer is valid as long as this object is.

bool SYS_SharedMemory::isValid ( ) const

Returns whether the shared memory is in a valid state for reading/writing. If the constructor failed to initialize the shared memory, an invalid shared memory size was supplied (such as 0), or the shared memory was closed, then this method will return false.

SYS_SharedMemory& SYS_SharedMemory::operator= ( const SYS_SharedMemory )
delete
bool SYS_SharedMemory::readOnly ( ) const

Returns true if this shared memory is read-only.

bool SYS_SharedMemory::reset ( exint  size,
const char *  id = nullptr 
)

Resets the shared memory to the given size and name, if specified. This has the effect of removing the previous shared memory segment (unless it's already open by someone else, in which case it gets deleted when that user closes it). If an id is not specified in the arguments, a new id() will be generated in order to avoid a potential conflict with potentially still opened previous shared memory section.

The shared memory cannot be reset if it was opened from an existing identifier.

static void SYS_SharedMemory::setTempDir ( const char *  path)
static

On some operating systems, shared memory is handled using a file system interface. On these systems, we need to know where the temporary files should be installed. This is typically in HOUDINI_TEMP_DIR.

Note: This is not thread safe, and should only be done once

exint SYS_SharedMemory::size ( ) const

Returns the size of the shared memory, in bytes.

Friends And Related Function Documentation

friend class SYS_SharedMemoryView
friend

Definition at line 91 of file SYS_SharedMemory.h.


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