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

A class used for the abstraction of semaphores. More...

#include <shared_memory.h>

Public Member Functions

 semaphore ()
 Empty semaphore constructor, clears all values. More...
 
 semaphore ()
 
 semaphore (const char *name, int oflag, mode_t mode, unsigned int value)
 Constructs a named semaphore. More...
 
 semaphore (const char *name, int oflag, mode_t mode, unsigned int value)
 
 ~semaphore ()
 The deconstructor. More...
 
 ~semaphore ()
 
void close ()
 Closes the currently opened semaphore. More...
 
void close ()
 
int getVal () const
 
int getVal () const
 Returns the current value of the semaphore. More...
 
void open (const char *name, int oflag, mode_t mode=0, unsigned int value=0)
 
void open (const char *name, int oflag, mode_t mode=0, unsigned int value=0)
 Opens a semaphore. More...
 
 operator bool () const
 
 operator bool () const
 Returns whether we have a valid semaphore. More...
 
void post ()
 
void post ()
 Posts to the semaphore, increases its value by one. More...
 
bool tryWait ()
 Tries to wait for the semaphore, returns true if successful, false otherwise. More...
 
bool tryWait ()
 
bool tryWaitOneSecond ()
 Tries to wait for the semaphore for a single second, returns true if successful, false otherwise. More...
 
bool tryWaitOneSecond ()
 
void unlink ()
 
void unlink ()
 Unlinks the previously opened semaphore. More...
 
void wait ()
 Waits for the semaphore, decreases its value by one. More...
 
void wait ()
 

Private Attributes

std::string myName
 
sem_t * mySem
 

Detailed Description

A class used for the abstraction of semaphores.

Constructor & Destructor Documentation

IPC::semaphore::semaphore ( )

Empty semaphore constructor, clears all values.

IPC::semaphore::semaphore ( const char *  name,
int  oflag,
mode_t  mode,
unsigned int  value 
)

Constructs a named semaphore.

Parameters
nameThe name of the semaphore
oflagThe flags with which to open the semaphore
modeThe mode in which to create the semaphore, if O_CREAT is given in oflag, ignored otherwise
valueThe initial value of the semaphore if O_CREAT is given in oflag, ignored otherwise
IPC::semaphore::~semaphore ( )

The deconstructor.

IPC::semaphore::semaphore ( )
IPC::semaphore::semaphore ( const char *  name,
int  oflag,
mode_t  mode,
unsigned int  value 
)
IPC::semaphore::~semaphore ( )

Member Function Documentation

void IPC::semaphore::close ( )

Closes the currently opened semaphore.

void IPC::semaphore::close ( )
int IPC::semaphore::getVal ( ) const

Returns the current value of the semaphore.

int IPC::semaphore::getVal ( ) const
void IPC::semaphore::open ( const char *  name,
int  oflag,
mode_t  mode = 0,
unsigned int  value = 0 
)
void IPC::semaphore::open ( const char *  name,
int  oflag,
mode_t  mode = 0,
unsigned int  value = 0 
)

Opens a semaphore.

Closes currently opened semaphore if needed

Parameters
nameThe name of the semaphore
oflagThe flags with which to open the semaphore
modeThe mode in which to create the semaphore, if O_CREAT is given in oflag, ignored otherwise
valueThe initial value of the semaphore if O_CREAT is given in oflag, ignored otherwise
IPC::semaphore::operator bool ( ) const

Returns whether we have a valid semaphore.

IPC::semaphore::operator bool ( ) const
void IPC::semaphore::post ( )

Posts to the semaphore, increases its value by one.

void IPC::semaphore::post ( )
bool IPC::semaphore::tryWait ( )

Tries to wait for the semaphore, returns true if successful, false otherwise.

bool IPC::semaphore::tryWait ( )
bool IPC::semaphore::tryWaitOneSecond ( )

Tries to wait for the semaphore for a single second, returns true if successful, false otherwise.

bool IPC::semaphore::tryWaitOneSecond ( )
void IPC::semaphore::unlink ( )
void IPC::semaphore::unlink ( )

Unlinks the previously opened semaphore.

void IPC::semaphore::wait ( )

Waits for the semaphore, decreases its value by one.

void IPC::semaphore::wait ( )

Field Documentation

std::string IPC::semaphore::myName
private
sem_t * IPC::semaphore::mySem
private

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