Wraps dispatch semaphores as provided by libDispatch/libXDispatch. More...
#include <QtDispatch/qdispatchsemaphore.h>
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 | tryAcquire (const QTime &) |
Tries to acquire the semaphore. | |
bool | tryAcquire (dispatch_time_t) |
bool | tryAcquire (struct tm *) |
int | release () |
Release the semaphore. | |
void | acquire () |
Acquires the semaphore. | |
bool | try_acquire (dispatch_time_t) |
Tries to acquire the semaphore. | |
bool | try_acquire (struct tm *) |
Tries to acquire the semaphore. | |
const dispatch_semaphore_t | native () const |
bool | operator== (const semaphore &) |
bool | operator== (const dispatch_semaphore_t &) |
bool | operator!= (const semaphore &) |
bool | operator!= (const dispatch_semaphore_t &) |
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."
Definition at line 43 of file qdispatchsemaphore.h.
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.
QDispatchSemaphore::QDispatchSemaphore | ( | const QDispatchSemaphore & | ) |
QDispatchSemaphore::QDispatchSemaphore | ( | dispatch_semaphore_t | ) |
QDispatchSemaphore::QDispatchSemaphore | ( | const xdispatch::semaphore & | ) |
QDispatchSemaphore::~QDispatchSemaphore | ( | ) |
void xdispatch::semaphore::acquire | ( | ) | [inherited] |
Acquires the semaphore.
Decrements the counting semaphore. If the value is less than zero it will wait until another thread released the semaphore.
const dispatch_semaphore_t xdispatch::semaphore::native | ( | ) | const [inherited] |
bool xdispatch::semaphore::operator!= | ( | const semaphore & | ) | [inherited] |
bool xdispatch::semaphore::operator!= | ( | const dispatch_semaphore_t & | ) | [inherited] |
bool xdispatch::semaphore::operator== | ( | const semaphore & | ) | [inherited] |
bool xdispatch::semaphore::operator== | ( | const dispatch_semaphore_t & | ) | [inherited] |
int xdispatch::semaphore::release | ( | ) | [inherited] |
Release the semaphore.
Increments the counting semaphore. If the previous value was less than zero, this function wakes a waiting thread before returning.
bool xdispatch::semaphore::try_acquire | ( | struct tm * | ) | [inherited] |
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.
bool xdispatch::semaphore::try_acquire | ( | dispatch_time_t | ) | [inherited] |
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.
bool QDispatchSemaphore::tryAcquire | ( | dispatch_time_t | ) |
bool QDispatchSemaphore::tryAcquire | ( | struct tm * | ) |
bool QDispatchSemaphore::tryAcquire | ( | 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.