Lockable
, TimedLockable
, Lockable
的基礎上加上了timeoutSharedLockable
, TimedLockable
基礎上,允許shared ownership(同時也支持exclusive)UpgradeLockable
, SharedLockable
基礎上,允許upgradable ownership(同時也支持shared、exclusive)SharedLockable
concept: unlock()
, just as if it had been acquired by a call to lock()
.lock_guard
Lockable
objectunique_lock
lock_guard
復雜在:不僅提供RAII-style的lock,還允許用戶指定是否在ctor中立即lock,意味著可以指定推遲lock(defer acquiring the lock,通過指定defer_lock_t參數),直到顯式調用其lock()方法TimedLockable
concept,前提是需要lock的Lockable object本身支持boost::unique_lock
are not thread-safe...[注:這句沒看懂。。。]shared_lock
upgrade_lock
upgrade_to_unique_lock
mutex
boost::mutex
實現了Lockable
concept,提供exclusive-ownership mutex. boost::mutex
at any time. lock()
, try_lock()
and unlock()
shall be permitted.try_mutex
timed_mutex
recursive_mutex
recursive_try_mutex
recursive_timed_mutex
shared_mutex
wait
on an instance of condition_variable
or condition_variable_any
. When the thread is woken from the wait, then it checks to see if the appropriate condition is now true, and continues if so. If the condition is not true, then the thread then calls wait
again to resume waiting.(中文參考)lock
is passed to wait()
; wait()
will atomically add the thread to the set of threads waiting on the condition variable, and unlock the mutex. When the thread is woken, the mutex will be locked again before the call to wait
returns. This allows other threads to acquire the mutex in order to update the shared data, and ensures that the data associated with the condition is correctly synchronized. In the mean time, another thread sets the condition to true
, and then calls either notify_one()
or notify_all()
on the condition variable to wake one waiting thread or all the waiting threads respectively.
boost::unique_lock<boost::mutex>類型;
condition_variable一般更優化只有注冊用戶登錄后才能發表評論。 | ||
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
![]() |
||
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
|
||
|