libXDispatch 0.4
Public Member Functions
QDispatchSemaphore Class Reference

Wraps dispatch semaphores as provided by libDispatch/libXDispatch. More...

Inheritance diagram for QDispatchSemaphore:

List of all members.

Public Member Functions

 QDispatchSemaphore (int=1)
 Constructs a new semaphore with the given initial value.
 QDispatchSemaphore (const QDispatchSemaphore &)
 QDispatchSemaphore (dispatch_semaphore_t)
 QDispatchSemaphore (const xdispatch::semaphore &)
 ~QDispatchSemaphore ()
bool try_acquire (const QTime &)
 Tries to acquire the semaphore.

Detailed Description

Wraps dispatch semaphores as provided by libDispatch/libXDispatch.

"A dispatch semaphore is an efficient implementation of a traditional counting semaphore. Dispatch semaphores call down to the kernel only when the calling thread needs to be blocked. If the calling semaphore does not need to block, no kernel call is made."


Constructor & Destructor Documentation

QDispatchSemaphore::QDispatchSemaphore ( int  = 1)

Constructs a new semaphore with the given initial value.

Passing zero for the value is useful for when two threads need to reconcile the completion of a particular event. Passing a value greather than zero is useful for managing a finite pool of resources, where the pool size is equal to the value.

Remarks:
Never pass a value less than zero here
QDispatchSemaphore::QDispatchSemaphore ( const QDispatchSemaphore )
QDispatchSemaphore::QDispatchSemaphore ( dispatch_semaphore_t  )
QDispatchSemaphore::QDispatchSemaphore ( const xdispatch::semaphore )
QDispatchSemaphore::~QDispatchSemaphore ( )

Member Function Documentation

bool QDispatchSemaphore::try_acquire ( const QTime &  )

Tries to acquire the semaphore.

Decrements the counting semaphore. If the value is less than zero it will wait until either another thread released the semaphore or the timeout passed.

Returns:
true if acquiring the semaphore succeeded.

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

Generated on Wed Feb 22 2012 19:51:17 for libXDispatch by Doxygen 1.7.4
Content © 2011-2012 MLBA (about | privacy) – Design © 2010-2012 Emzeat. All Rights reserved.