MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
Public Member Functions | Data Fields
IPC::sharedPage Class Reference

A class for handling shared memory pages. More...

#include <shared_memory.h>

Inheritance diagram for IPC::sharedPage:
IPC::sharedFile IPC::sharedFile

Public Member Functions

 sharedPage (std::string name_="", unsigned int len_=0, bool master_=false, bool autoBackoff=true)
 brief Creates a shared page More...
 
 sharedPage (std::string name_="", unsigned int len_=0, bool master_=false, bool autoBackoff=true)
 
 sharedPage (const sharedPage &rhs)
 Creates a copy of a shared page. More...
 
 sharedPage (const sharedPage &rhs)
 
 ~sharedPage ()
 Default destructor. More...
 
 ~sharedPage ()
 
void close ()
 Unmaps, closes and unlinks (if master and name is set) the shared file. More...
 
void close ()
 
void init (std::string name_, unsigned int len_, bool master_=false, bool autoBackoff=true)
 Initialize a page, de-initialize before if needed. More...
 
void init (std::string name_, unsigned int len_, bool master_=false, bool autoBackoff=true)
 
 operator bool () const
 
 operator bool () const
 Returns whether the shared file is valid or not. More...
 
bool operator< (const sharedFile &rhs) const
 
bool operator< (const sharedFile &rhs) const
 
void unmap ()
 Unmaps a shared file if allowed. More...
 
void unmap ()
 

Data Fields

int handle
 The fd handle of the opened shared file. More...
 
long long int len
 The size in bytes of the opened shared file. More...
 
char * mapped
 A pointer to the payload of the file file. More...
 
bool master
 Whether this class should unlink the shared file upon deletion or not. More...
 
std::string name
 The name of the opened shared file. More...
 

Detailed Description

A class for handling shared memory pages.

Uses shared files at its backbone, defined for portability

Constructor & Destructor Documentation

IPC::sharedPage::sharedPage ( std::string  name_ = "",
unsigned int  len_ = 0,
bool  master_ = false,
bool  autoBackoff = true 
)

brief Creates a shared page

Parameters
name_The name of the page to be created
len_The size to make the page
master_Whether to create or merely open the page
autoBackoffWhen only opening the page, wait for it to appear or fail
IPC::sharedPage::sharedPage ( const sharedPage rhs)

Creates a copy of a shared page.

Parameters
rhsThe page to copy
IPC::sharedPage::~sharedPage ( )

Default destructor.

IPC::sharedPage::sharedPage ( std::string  name_ = "",
unsigned int  len_ = 0,
bool  master_ = false,
bool  autoBackoff = true 
)
IPC::sharedPage::sharedPage ( const sharedPage rhs)
IPC::sharedPage::~sharedPage ( )

Member Function Documentation

void IPC::sharedFile::close ( )
inherited

Unmaps, closes and unlinks (if master and name is set) the shared file.

void IPC::sharedFile::close ( )
inherited
void IPC::sharedFile::init ( std::string  name_,
unsigned int  len_,
bool  master_ = false,
bool  autoBackoff = true 
)
inherited
void IPC::sharedFile::init ( std::string  name_,
unsigned int  len_,
bool  master_ = false,
bool  autoBackoff = true 
)
inherited

Initialize a page, de-initialize before if needed.

Parameters
name_The name of the page to be created
len_The size to make the page
master_Whether to create or merely open the page
autoBackoffWhen only opening the page, wait for it to appear or fail
Todo:
Use ACCESSPERMS instead of 0600?
IPC::sharedFile::operator bool ( ) const
inherited
IPC::sharedFile::operator bool ( ) const
inherited

Returns whether the shared file is valid or not.

bool IPC::sharedFile::operator< ( const sharedFile rhs) const
inlineinherited
bool IPC::sharedFile::operator< ( const sharedFile rhs) const
inlineinherited
void IPC::sharedFile::unmap ( )
inherited

Unmaps a shared file if allowed.

void IPC::sharedFile::unmap ( )
inherited

Field Documentation

int IPC::sharedFile::handle
inherited

The fd handle of the opened shared file.

long long int IPC::sharedFile::len
inherited

The size in bytes of the opened shared file.

char * IPC::sharedFile::mapped
inherited

A pointer to the payload of the file file.

bool IPC::sharedFile::master
inherited

Whether this class should unlink the shared file upon deletion or not.

std::string IPC::sharedFile::name
inherited

The name of the opened shared file.


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