Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Semaphore Class Reference

Binary semaphore. More...

#include <semaphore.h>

List of all members.

Public Methods

 Semaphore (const String &name)
 Constructor. More...

 ~Semaphore ()
 Destructor.

void wait ()
 Lock semaphore. More...

void release ()
 Unlock semaphore. More...

void reset ()
 Reset semaphore. More...


Private Attributes

int _semid
 unix semaphore identifier.


Detailed Description

Binary semaphore.

This class implements IPC semaphore. Implementation of this class is platform/system dependent. Semaphore is automatically locked after it is created.

Author:
Marek Przeczek

Definition at line 47 of file semaphore.h.


Constructor & Destructor Documentation

Semaphore::Semaphore const String   name
 

Constructor.

Opens a semaphore with given name. If semaphore doesn't exist, new one is created. It is automatically locked after it is created.

Parameters:
name  unique name (4 characters long only)

Definition at line 37 of file semaphore.cpp.


Member Function Documentation

void Semaphore::release  
 

Unlock semaphore.

This method releases semaphore locked by previous call to wait() method.

See also:
wait()

Definition at line 70 of file semaphore.cpp.

Referenced by CommunShMem::initialize(), CommunShMem::operator<<(), CommunShMem::operator>>(), and CommunShMem::~CommunShMem().

void Semaphore::reset  
 

Reset semaphore.

It resets semaphore and sets its default value (locked by one). Implemented only on Unix systems because of troubles with JVM.

Definition at line 80 of file semaphore.cpp.

Referenced by Semaphore(), CommunShMem::initialize(), and CommunShMem::~CommunShMem().

void Semaphore::wait  
 

Lock semaphore.

If the semaphore is already locked, calling thread waits on semaphore until another process (or thread) will release it.

See also:
release()

Definition at line 60 of file semaphore.cpp.

Referenced by CommunShMem::initialize(), CommunShMem::isReady(), CommunShMem::operator<<(), and CommunShMem::operator>>().


The documentation for this class was generated from the following files:
Generated on Mon Jan 28 14:53:30 2002 for Java Profiler Dynamic Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001