AXCEL C++ Framework
Elegance through abstraction
Public Member Functions | Public Attributes
axcel::proc::semaphore Class Reference

Semaphore. More...

#include <axcel.h>

Inheritance diagram for axcel::proc::semaphore:
axcel::object

List of all members.

Public Member Functions

virtual string type ()
 Get type of object.
virtual operator string ()
 Convert to string.
 semaphore ()
 semaphore (size_t count)
 semaphore (const char *name)
 ~semaphore ()
bool init (size_t count)
bool die ()
bool open (const char *name)
bool close ()
bool get (size_t ms=0)
bool tryget ()
bool ret ()

Public Attributes

sem_t * id
bool named

Detailed Description

Semaphore.

Semaphores allow processes and threads to synchronize their actions. Think of a semaphore as a rental service, there's a set amount of items to lend to threads/processes. Once there's no more items to lend out to someone, that person will wait until someone else who is renting one of those items returns it. Likewise a semaphore is an integer; each thread that wants to access an associated resource will first decrement this integer. Once that thread is done with the resource, it will increment the semaphore. If a thread tries to decrement a semaphore whose value is zero, then that thread will block (or fail to access the resource if non-blocking) until another thread releases the resource and increments the semaphore.

Definition at line 2093 of file axcel.h.


Constructor & Destructor Documentation

axcel::proc::semaphore::semaphore ( ) [inline]

Definition at line 2103 of file axcel.h.

axcel::proc::semaphore::semaphore ( size_t  count)

Definition at line 6595 of file axcel.cpp.

axcel::proc::semaphore::semaphore ( const char *  name)

Definition at line 6596 of file axcel.cpp.

axcel::proc::semaphore::~semaphore ( )

Definition at line 6597 of file axcel.cpp.


Member Function Documentation

bool axcel::proc::semaphore::close ( )

Definition at line 6600 of file axcel.cpp.

bool axcel::proc::semaphore::die ( )

Definition at line 6599 of file axcel.cpp.

bool axcel::proc::semaphore::get ( size_t  ms = 0)

Definition at line 6612 of file axcel.cpp.

bool axcel::proc::semaphore::init ( size_t  count)

Definition at line 6598 of file axcel.cpp.

bool axcel::proc::semaphore::open ( const char *  name)

Definition at line 6601 of file axcel.cpp.

axcel::proc::semaphore::operator string ( ) [virtual]

Convert to string.

Returns:
Suitable string representation of object's data

Implements axcel::object.

Definition at line 291 of file axcel.cpp.

bool axcel::proc::semaphore::ret ( )

Definition at line 6622 of file axcel.cpp.

bool axcel::proc::semaphore::tryget ( )

Definition at line 6621 of file axcel.cpp.

string axcel::proc::semaphore::type ( ) [virtual]

Get type of object.

Returns:
string containing name of object's class.

Implements axcel::object.

Definition at line 266 of file axcel.cpp.


Member Data Documentation

Definition at line 2100 of file axcel.h.

Definition at line 2102 of file axcel.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Defines