POSIX shared memory segment. More...

#include <Segment.h>

Collaboration diagram for Ipc::Mem::Segment:

Public Member Functions

 Segment (const char *const id)
 Create a shared memory segment. More...
 
 ~Segment ()
 
void create (const off_t aSize)
 Create a new shared memory segment. Unlinks the segment on destruction. More...
 
void open (const bool unlinkWhenDone)
 
const Stringname ()
 shared memory segment name More...
 
off_t size ()
 shared memory segment size More...
 
void * mem ()
 pointer to the next chunk More...
 
void * reserve (size_t chunkSize)
 reserve and return the next chunk More...
 

Static Public Member Functions

static bool Enabled ()
 Whether shared memory support is available. More...
 
static SBuf Name (const SBuf &prefix, const char *suffix)
 concatenates parts of a name to form a complete name (or its prefix) More...
 

Static Public Attributes

static const char * BasePath = DEFAULT_STATEDIR
 common path of all segment names in path-based environments More...
 

Private Member Functions

 Segment (const Segment &)
 
Segmentoperator= (const Segment &)
 
void checkSupport (const char *const context)
 

Private Attributes

const String theName
 shared memory segment file name More...
 
void * theMem
 pointer to mmapped shared memory segment More...
 
off_t theSize
 shared memory segment size More...
 
off_t theReserved
 the total number of reserve()d bytes More...
 
bool doUnlink
 whether the segment should be unlinked on destruction More...
 

Detailed Description

Definition at line 23 of file Segment.h.

Constructor & Destructor Documentation

◆ Segment() [1/2]

Ipc::Mem::Segment::Segment ( const char *const  id)

Definition at line 306 of file Segment.cc.

◆ ~Segment()

Ipc::Mem::Segment::~Segment ( )

Definition at line 311 of file Segment.cc.

References debugs, and Segments.

◆ Segment() [2/2]

Ipc::Mem::Segment::Segment ( const Segment )
private

Member Function Documentation

◆ checkSupport()

void Ipc::Mem::Segment::checkSupport ( const char *const  context)
private

Definition at line 363 of file Segment.cc.

References debugs, and fatalf().

◆ create()

void Ipc::Mem::Segment::create ( const off_t  aSize)

Definition at line 328 of file Segment.cc.

References assert, debugs, fatalf(), and Segments.

Referenced by Ipc::Mem::Owner< Class >::Owner().

◆ Enabled()

bool Ipc::Mem::Segment::Enabled ( )
static

Definition at line 322 of file Segment.cc.

References IamWorkerProcess(), and UsingSmp().

Referenced by MemStoreRr::finalizeConfig().

◆ mem()

void * Ipc::Mem::Segment::mem ( )
inline

Definition at line 41 of file Segment.h.

References reserve().

Referenced by Ipc::Mem::Object< Class >::Object(), and Ipc::Mem::Owner< Class >::Owner().

◆ name()

const String & Ipc::Mem::Segment::name ( )
inline

Definition at line 39 of file Segment.h.

References theName.

◆ Name()

SBuf Ipc::Mem::Segment::Name ( const SBuf prefix,
const char *  suffix 
)
static

◆ open()

void Ipc::Mem::Segment::open ( const bool  unlinkWhenDone)

opens an existing shared memory segment

Parameters
unlinkWhenDonewhether to delete the segment on destruction

Definition at line 346 of file Segment.cc.

References assert, debugs, fatalf(), Segments, theMem, and theSize.

Referenced by Ipc::Mem::Object< Class >::Object(), and Ipc::Mem::Owner< Class >::Owner().

◆ operator=()

Segment & Ipc::Mem::Segment::operator= ( const Segment )
private

◆ reserve()

void * Ipc::Mem::Segment::reserve ( size_t  chunkSize)

Definition at line 38 of file Segment.cc.

References assert, Must, theMem, theReserved, and theSize.

Referenced by mem(), and Ipc::Mem::Owner< Class >::New().

◆ size()

off_t Ipc::Mem::Segment::size ( )
inline

Definition at line 40 of file Segment.h.

References theSize.

Referenced by Ipc::Mem::Object< Class >::Object().

Member Data Documentation

◆ BasePath

const char * Ipc::Mem::Segment::BasePath = DEFAULT_STATEDIR
static

Definition at line 45 of file Segment.h.

◆ doUnlink

bool Ipc::Mem::Segment::doUnlink
private

Definition at line 79 of file Segment.h.

◆ theMem

void* Ipc::Mem::Segment::theMem
private

Definition at line 76 of file Segment.h.

Referenced by open(), and reserve().

◆ theName

const String Ipc::Mem::Segment::theName
private

Definition at line 75 of file Segment.h.

Referenced by name().

◆ theReserved

off_t Ipc::Mem::Segment::theReserved
private

Definition at line 78 of file Segment.h.

Referenced by reserve().

◆ theSize

off_t Ipc::Mem::Segment::theSize
private

Definition at line 77 of file Segment.h.

Referenced by open(), reserve(), and size().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors