122 Q_ASSERT_X(n >= 0,
"QSemaphore",
"parameter 'n' must be non-negative");
144 Q_ASSERT_X(n >= 0,
"QSemaphore::acquire",
"parameter 'n' must be non-negative");
147 d->cond.wait(locker.
mutex());
163 Q_ASSERT_X(n >= 0,
"QSemaphore::release",
"parameter 'n' must be non-negative");
194 Q_ASSERT_X(n >= 0,
"QSemaphore::tryAcquire",
"parameter 'n' must be non-negative");
220 Q_ASSERT_X(n >= 0,
"QSemaphore::tryAcquire",
"parameter 'n' must be non-negative");
224 d->cond.wait(locker.
mutex());
228 while (n >
d->avail) {
230 if (timeout - elapsed <= 0
243 #endif // QT_NO_THREAD
static double elapsed(qint64 after, qint64 before)
#define QT_END_NAMESPACE
This macro expands to.
The QMutex class provides access serialization between threads.
void release(int n=1)
Releases n resources guarded by the semaphore.
bool tryAcquire(int n=1)
Tries to acquire n resources guarded by the semaphore and returns true on success.
int available() const
Returns the number of resources currently available to the semaphore.
The QElapsedTimer class provides a fast way to calculate elapsed times.
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QSemaphore(int n=0)
Creates a new semaphore and initializes the number of resources it guards to n (by default...
void acquire(int n=1)
Tries to acquire n resources guarded by the semaphore.
#define Q_ASSERT_X(cond, where, what)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
void start()
Starts this timer.
~QSemaphore()
Destroys the semaphore.
QMutex * mutex() const
Returns a pointer to the mutex that was locked in the constructor.