Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

OW32::CSemaphore Class Reference

Wrapper for a Win32 semaphore object. More...

#include <SyncObjects.h>

Inheritance diagram for OW32::CSemaphore:

OW32::CSyncObject List of all members.

Public Member Functions

 CSemaphore (LONG lMaximumCount, LONG lInitialCount=0, LPCTSTR lpszName=NULL, LPSECURITY_ATTRIBUTES lpSecAttr=NULL)
 Construct a new semaphore object.
 CSemaphore (HANDLE hSemaphore)
 Construct a new semaphore object.
CSemaphoreoperator= (HANDLE hSemaphore)
 Set the encapsulated semaphore handle.
virtual BOOL Lock (DWORD dwTimeout=INFINITE)
 Wait for the semaphore's count to become non-zero.
void Unlock ()
 Unused.
BOOL Release (LONG lReleaseCount, LPLONG lPreviousCount=NULL)
 Increment the semaphore's count.
 operator HANDLE () const
 HANDLE extractor for the semaphore object.

Detailed Description

Wrapper for a Win32 semaphore object.

A semaphore is a counting object, the count ranges between zero and a user specified maximum value. The state of a semaphore is signaled when its count is greater than zero and nonsignaled when it is zero. The count is decreased by one whenever a wait function releases a thread that was waiting for the semaphore. The count is increased by a specified amount by calling the Release function.


Constructor & Destructor Documentation

OW32::CSemaphore::CSemaphore LONG  lMaximumCount,
LONG  lInitialCount = 0,
LPCTSTR  lpszName = NULL,
LPSECURITY_ATTRIBUTES  lpSecAttr = NULL
[inline]
 

Construct a new semaphore object.

Parameters:
lMaximumCount The maximum count of the semaphore object
lInitialCount The initial count of the semaphore object
lpszName The object's name
lpSecAttr security descriptor for the object

OW32::CSemaphore::CSemaphore HANDLE  hSemaphore  )  [inline]
 

Construct a new semaphore object.

Parameters:
hSemaphore Existing semaphore to encapsulate


Member Function Documentation

virtual BOOL OW32::CSemaphore::Lock DWORD  dwTimeout = INFINITE  )  [inline, virtual]
 

Wait for the semaphore's count to become non-zero.

Returns:
TRUE if successful, FALSE otherwise
Parameters:
dwTimeout The length of time to wait for lock acquisition

Implements OW32::CSyncObject.

CSemaphore& OW32::CSemaphore::operator= HANDLE  hSemaphore  )  [inline]
 

Set the encapsulated semaphore handle.

Parameters:
hSemaphore the new semaphore

BOOL OW32::CSemaphore::Release LONG  lReleaseCount,
LPLONG  lPreviousCount = NULL
[inline]
 

Increment the semaphore's count.

Returns:
TRUE if successful, FALSE otherwise
Parameters:
lReleaseCount the number to increment the count by
lPreviousCount Output - the previous count of the semaphore


The documentation for this class was generated from the following file:
Generated on Sun Jun 5 01:29:29 2005 for OW32 by  doxygen 1.3.9.1