Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

phSemaphore Class Reference
[Threading and SynchronizationThread Safe]

#include <phSemaphore.h>

Inheritance diagram for phSemaphore:

phMutex phObject phLiveCookie List of all members.

Detailed Description

This class implements a thread safe portable semaphore class. It extend the normal interface of a semaphore with the phSemaphore::postWaiting and phSemaphore::postMax methods. This semaphore object will keep track of the number of waiting threads at any instance in time to allow them to all be 'woken up' if necessary to permit the proper shutdown or cleanup of a thread or series of threads. Being able to post the maximum number of semaphores possible without any of the threads returning until all the semaphores are posted can be useful in synchronization. Otherwise, the semaphores can be posted one at a time.

Todo:
add setMax

Definition at line 118 of file phSemaphore.h.

Public Member Functions

 phSemaphore (uint32_t value=0, uint32_t max=phSemVALUEMAX)
 ~phSemaphore ()
int copy (phObject *copyto_obj)
int swap (phObject *obj)
int post (uint32_t value=1)
int postToWaiting (uint32_t minimum=1)
int postMax ()
int take (uint32_t flag=phSemaphoreWAIT)
int tryTake ()
uint32_t getValue ()
uint32_t getWaitingCount ()
uint32_t getMax ()

Private Attributes

ph_semaphore_info m_info
uint32_t m_count
uint32_t m_waiting
uint32_t m_max


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



Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:45:11 2007 for phission by  doxygen 1.4.4