Qt例程之Semaphore

The QSemaphore class provides a general counting semaphore.
//計數信號量

void QSemaphore::acquire(int n = 1)
Tries to acquire n resources guarded by the semaphore. If n > available(),
//試圖由semaphore 保護的n個資源,如果n>可用的,這個調用會阻塞,直到所有資源可用
this call will block until enough resources are available.

int QSemaphore::available() const
Returns the number of resources currently available to the semaphore.
//返回semaphore可用的資源的數量,
This number can never be negative.

void QSemaphore::release(int n = 1)
Releases n resources guarded by the semaphore.
//釋放由semaphore保護的n個資源

[slot]
void QThread::start(Priority priority = InheritPriority)

Begins execution of the thread by calling run(). The operating system will schedule the thread
//通過調用run()來執行thread。os會根據優先級調度thread
according to the priority parameter. If the thread is already running, this function does nothing.

bool QThread::wait(unsigned long time = ULONG_MAX)
Blocks the thread until either of these conditions is met:
//阻塞thread,直到這些條件滿足

The thread associated with this QThread object has finished execution (i.e. when it returns from run()).
//thread已經執行
This function will return true if the thread has finished. It also returns true if the thread has not been started yet.
//如果thread完成就返回真
time milliseconds has elapsed. If time is ULONG_MAX (the default), then the wait will never timeout (the thread must return from run()).
This function will return false if the wait timed out.
//時間到期,ULONG_MAX永遠不會超時

bool QThread::isRunning() const
Returns true if the thread is running; otherwise returns false.
//當thread在運行時,返回真

void QThread::start(Priority priority = InheritPriority)
Begins execution of the thread by calling run().
//調用run開始執行thread
The operating system will schedule the thread according to the priority parameter. If the thread is already running, this function does nothing.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章