User Documentation
RAVL, Recognition And Vision Library
DEVELOP HOME PAGE CLASS LIST CONTENTS
Ravl - OS - Threads - SemaphoreC
 

  PUBLIC
SemaphoreC::SemaphoreC(int)
SemaphoreC::SemaphoreC(const SemaphoreC &)
SemaphoreC::Wait(void)
SemaphoreC::Wait(RealT)
SemaphoreC::TryWait(void)
SemaphoreC::Post(void)
SemaphoreC::Count(void) const

   SemaphoreC   
 
Semaphore.
 
include "Ravl/Threads/Semaphore.hh"
Created:25/5/1998 
User Level:Normal
Library:RavlThreads
In Scope:RavlN

Comments:
This is a method for communicating between threads. It includes an atomic counter, which can be incremented by Post(), and decremented by Wait(). Wait() will only when it can decrement the counter from a positive number. One use of this class is to send a signal to another thread that some processing is ready to be done.

Variables:
Methods:
SemaphoreC(int initVal = 1)
Constructor.
Create a semaphore with an inital count of 'initVal'.

SemaphoreC(const SemaphoreC & oth)
Copy Constructor.
Create a semaphore with the same count as this one. Its not clear how useful this really is.

bool Wait()
Wait for semaphore.
Test is semaphore has a count greated than 0, if it does decrement it and return. If the count is 0, then wait until it a call to Post() increments it, then decrement it and return true.

bool Wait(RealT maxDelay)
Wait for semaphore.
As Wait(), but only wait for semaphore for up to 'maxDelay' seconds. If the time expires return false. If the semaphore is recieved then return true.

bool TryWait()
Try and wait for semaphore
Return true if semaphore has been posted, and decrement as it Wait() had been called. Otherwise do nothing and return false.

bool Post()
Post a semaphore.
Post a semaphore, increase the semaphore count by 1.

int Count(void) const
Read semaphore count.


Maintainer:Charles Galambos, Created: 25/5/1998, Documentation by CxxDoc: Tue Aug 13 09:59:02 2002