MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
Public Member Functions | Private Attributes
IPC::sharedClient Class Reference

The client part of a server/client model for shared memory. More...

#include <shared_memory.h>

Public Member Functions

 sharedClient ()
 Creates an empty shared client. More...
 
 sharedClient ()
 
 sharedClient (const sharedClient &rhs)
 Copy constructor for sharedClients. More...
 
 sharedClient (const sharedClient &rhs)
 
 sharedClient (std::string name, int len, bool withCounter=false)
 SharedClient Constructor, allocates space on the correct page. More...
 
 sharedClient (std::string name, int len, bool withCounter=false)
 
 ~sharedClient ()
 The deconstructor. More...
 
 ~sharedClient ()
 
void finish ()
 
void finish ()
 Indicate that the process is done using this piece of memory, set the counter to finished. More...
 
char * getData ()
 Get a pointer to the data of this client. More...
 
char * getData ()
 
void keepAlive ()
 Re-initialize the counter. More...
 
void keepAlive ()
 
void operator= (const sharedClient &rhs)
 
void operator= (const sharedClient &rhs)
 Assignment operator. More...
 
void write (char *data, int len)
 
void write (char *data, int len)
 Writes data to the shared data. More...
 

Private Attributes

std::string baseName
 The basename of the shared pages. More...
 
bool hasCounter
 Whether the payload has a counter, if so, it is added in front of the payload. More...
 
sharedPage myPage
 The shared page this client has reserved a space on. More...
 
semaphore mySemaphore
 A semaphore that is locked upon trying to allocate space on a page. More...
 
int offsetOnPage
 The offset of the payload reserved for this client within the opened page. More...
 
int payLen
 The size in bytes of the opened page. More...
 

Detailed Description

The client part of a server/client model for shared memory.

The server manages the shared memory pages, and allocates new pages when needed.

Pages are created with a basename + index, where index is in the range of 'A' - 'Z' Each time a page is nearly full, the next page is created with a size double to the previous one.

Clients should allocate payLen bytes at a time, possibly with the addition of a counter. If no such length can be allocated, the next page should be tried, and so on.

Constructor & Destructor Documentation

IPC::sharedClient::sharedClient ( )

Creates an empty shared client.

IPC::sharedClient::sharedClient ( const sharedClient rhs)

Copy constructor for sharedClients.

Parameters
rhsThe client ro copy
IPC::sharedClient::sharedClient ( std::string  name,
int  len,
bool  withCounter = false 
)

SharedClient Constructor, allocates space on the correct page.

Parameters
nameThe basename of the server to connect to
lenThe size of the payload to allocate
withCounterWhether or not this payload has a counter
IPC::sharedClient::~sharedClient ( )

The deconstructor.

IPC::sharedClient::sharedClient ( )
IPC::sharedClient::sharedClient ( const sharedClient rhs)
IPC::sharedClient::sharedClient ( std::string  name,
int  len,
bool  withCounter = false 
)
IPC::sharedClient::~sharedClient ( )

Member Function Documentation

void IPC::sharedClient::finish ( )

Indicate that the process is done using this piece of memory, set the counter to finished.

void IPC::sharedClient::finish ( )
char * IPC::sharedClient::getData ( )

Get a pointer to the data of this client.

char* IPC::sharedClient::getData ( )
void IPC::sharedClient::keepAlive ( )

Re-initialize the counter.

void IPC::sharedClient::keepAlive ( )
void IPC::sharedClient::operator= ( const sharedClient rhs)
void IPC::sharedClient::operator= ( const sharedClient rhs)

Assignment operator.

void IPC::sharedClient::write ( char *  data,
int  len 
)

Writes data to the shared data.

void IPC::sharedClient::write ( char *  data,
int  len 
)

Field Documentation

std::string IPC::sharedClient::baseName
private

The basename of the shared pages.

bool IPC::sharedClient::hasCounter
private

Whether the payload has a counter, if so, it is added in front of the payload.

sharedPage IPC::sharedClient::myPage
private

The shared page this client has reserved a space on.

semaphore IPC::sharedClient::mySemaphore
private

A semaphore that is locked upon trying to allocate space on a page.

int IPC::sharedClient::offsetOnPage
private

The offset of the payload reserved for this client within the opened page.

int IPC::sharedClient::payLen
private

The size in bytes of the opened page.


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