青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html

Mutex概念
線程同步最基本的是mutex(mutual exclusion的縮寫(xiě))。一個(gè)互斥體一次只允許一個(gè)線程訪問(wèn)共享區(qū)。當(dāng)一個(gè)線程想要訪問(wèn)共享區(qū)時(shí),首先要做的就是鎖住(lock)互斥體。如果其他的 線程已經(jīng)鎖住了互斥體,那么就必須先等那個(gè)線程將互斥體解鎖,這樣就保證了同一時(shí)刻只有一個(gè)線程能訪問(wèn)共享區(qū)域。

Boost.Thread supplies recursive and non-recursive mutexes with exclusive ownership(獨(dú)占) semantics, along with a shared ownership (共享) (multiple-reader / single-writer) mutex.
Boost.Thread supports four basic concepts for lockable objects:

Lockable,
exclusive ownership
TimedLockable,
Lockable的基礎(chǔ)上加上了timeout
SharedLockable,
TimedLockable基礎(chǔ)上,允許shared ownership(同時(shí)也支持exclusive)
This is the standard multiple-reader / single-write model:
at most one thread can have exclusive ownership, and if any thread does have exclusive ownership, no other threads can have shared or exclusive ownership. Alternatively, many threads may have shared ownership.
UpgradeLockable,
SharedLockable基礎(chǔ)上,允許upgradable ownership(同時(shí)也支持shared、exclusive)
This is an extension to the multiple-reader / single-write model provided by the SharedLockable concept:
a single thread may have upgradable ownership at the same time as others have shared ownership. The thread with upgradable ownership may at any time attempt to upgrade that ownership to exclusive ownership. If no other threads have shared ownership, the upgrade is completed immediately, and the thread now has exclusive ownership, which must be relinquished by a call to unlock(), just as if it had been acquired by a call to lock().

[注:除Lockable的mutex外,其余的各種復(fù)雜mutex還需要更多代碼實(shí)踐]

Each mutex type implements one or more of these concepts, as do the various lock types.

Lock Types
boost定義的Lock types為class template,以合適的Lockable object作為模板參數(shù)
lock_guard
RAII-style的簡(jiǎn)單lock,在ctor中l(wèi)ock,在dtor中unlock
只支持簡(jiǎn)單的Lockable object
unique_lock
lock_guard復(fù)雜在:不僅提供RAII-style的lock,還允許用戶指定是否在ctor中立即lock,意味著可以指定推遲lock(defer acquiring the lock,通過(guò)指定defer_lock_t參數(shù)),直到顯式調(diào)用其lock()方法
還支持TimedLockable concept,前提是需要lock的Lockable object本身支持
The member functions of boost::unique_lock are not thread-safe...[注:這句沒(méi)看懂。。。]

shared_lock
upgrade_lock
upgrade_to_unique_lock

[注:目前只用過(guò)unique_lock。后面幾種對(duì)應(yīng)于不同需求的lock,從名字就可以直觀看出功能,還未試驗(yàn),直接參考api]
Mutex Types
Mutex types對(duì)應(yīng)于之前的mutex concepts,目前有:
Class mutex
boost::mutex實(shí)現(xiàn)了Lockable concept,提供exclusive-ownership mutex.
At most one thread can own the lock on a given instance of boost::mutex at any time.
Multiple concurrent calls to lock(), try_lock() and unlock() shall be permitted.

typedef unique_lock mutex::scoped_lock;

Typedef try_mutex
Class timed_mutex
Class recursive_mutex
Typedef recursive_try_mutex
Class recursive_timed_mutex
Class shared_mutex
適用于不同需求


Condition Variables
The general usage pattern is that one thread locks a mutex and then calls 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.


condition_variable_any比condition_variable更通用;condition_variable要求傳給wait()的必須是boost::unique_lock<boost::mutex>類型;condition_variable一般更優(yōu)化

One-time Initialization
僅運(yùn)行一次的例程
http://www.stlchina.org/twiki/bin/view.pl/Main/BoostThread#5%20%BD%F6%D4%CB%D0%D0%D2%BB%B4%CE%B5%C4%C0%FD%B3%CC
[注:還未使用過(guò)]

Barriers
[注:還未使用過(guò)]



posted on 2008-04-29 14:28 frank28_nfls 閱讀(668) 評(píng)論(0)  編輯 收藏 引用

只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


 
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美日韩在线免费观看| 欧美aaaaaaaa牛牛影院| 亚洲视频二区| 西西人体一区二区| 久久久免费观看视频| 亚洲大胆人体视频| 国产精品久久久久久久久久免费| 老司机久久99久久精品播放免费| 欧美韩日一区| 国产日产欧美a一级在线| 亚洲大片在线| 亚洲欧美日韩国产成人精品影院| 久久久最新网址| 老司机aⅴ在线精品导航| 日韩一区二区精品葵司在线| 欧美在线一二三区| 99在线热播精品免费| 久久精品国产免费| 国产精品每日更新| 毛片基地黄久久久久久天堂| 亚洲一区在线看| 欧美精品123区| 国产自产在线视频一区| 亚洲一区二区在线播放| 91久久久精品| 久久青草欧美一区二区三区| 国产精品美女久久久久久久| 蜜桃av噜噜一区| 久久福利一区| 一区二区电影免费观看| 亚洲激情另类| 国产亚洲人成网站在线观看| 欧美影院视频| 亚洲综合首页| 国产伦精品一区二区三区四区免费| 一本大道av伊人久久综合| 亚洲黄色尤物视频| 国产一区二区三区日韩| 日韩亚洲欧美综合| 国产精品成人免费视频 | 免费在线播放第一区高清av| 国内外成人免费激情在线视频| 亚洲国产一区二区精品专区| 欧美成人激情视频| 亚洲精品你懂的| 亚洲国产你懂的| 好看的av在线不卡观看| 久久免费观看视频| 国产精品男女猛烈高潮激情| 亚洲精品一区二区三区婷婷月| 欧美日韩精品三区| 亚洲欧美日韩综合国产aⅴ| 亚洲嫩草精品久久| 亚洲视频一区二区| 欧美电影电视剧在线观看| 免费观看亚洲视频大全| 国产自产在线视频一区| 羞羞色国产精品| 欧美午夜精品久久久久久人妖| 午夜视频一区在线观看| 欧美午夜精彩| 99热这里只有成人精品国产| 一二三四社区欧美黄| 欧美成人免费在线观看| 亚洲国产欧美不卡在线观看| 亚洲欧洲日本在线| 亚洲一区二区三区午夜| 午夜精品福利在线| 国产精品午夜在线| 亚洲国产三级| 一本一本久久| 国产精品久久国产精麻豆99网站| 在线视频精品一区| 亚洲国产免费| 先锋影音久久久| 久久久www成人免费精品| 欧美激情在线播放| 日韩一区二区免费看| 一区二区三区黄色| 国产精品亚洲综合一区在线观看| 亚洲一区国产精品| 久久久久久噜噜噜久久久精品| 精品不卡在线| 亚洲专区国产精品| 久久综合中文字幕| 亚洲精品少妇| 国产精品久久久久aaaa樱花| 亚洲欧美日韩综合国产aⅴ| 99ri日韩精品视频| 国产精品美女午夜av| 久久精品99国产精品日本| 欧美福利精品| 国内精品伊人久久久久av一坑| 久久久久久久久伊人| 欧美在线看片a免费观看| 一区二区三区在线免费观看| 欧美电影在线免费观看网站| 亚洲一区二区三区影院| 老司机午夜精品视频| 夜夜夜精品看看| 国产一区二区视频在线观看| 欧美国产激情二区三区| 亚洲女人天堂av| 亚洲国产成人精品视频| 欧美中文字幕第一页| 亚洲三级影片| 国产在线欧美日韩| 欧美日一区二区在线观看| 久久久久久久97| 亚洲资源在线观看| 亚洲国产色一区| 久久亚洲国产精品一区二区| 国语自产精品视频在线看| 欧美精品一区二区三区在线看午夜| 欧美成人综合一区| 欧美一区二区女人| 99re热这里只有精品免费视频| 韩国av一区二区三区| 国产精品vvv| 欧美成在线观看| 久久嫩草精品久久久久| 亚洲免费在线| 99综合视频| 亚洲人成毛片在线播放女女| 99视频在线精品国自产拍免费观看| 国产香蕉97碰碰久久人人| 欧美一区二区三区精品| 99国产精品一区| 最新国产成人在线观看| 久久综合色8888| 欧美制服第一页| 亚洲欧美成人一区二区在线电影 | 欧美日韩不卡合集视频| 久久久伊人欧美| 久久riav二区三区| 欧美大片91| 浪潮色综合久久天堂| 久久久夜夜夜| 久久精品盗摄| 亚洲精品社区| 亚洲区免费影片| 最新中文字幕一区二区三区| 亚洲缚视频在线观看| 欧美日韩视频不卡| 亚洲欧美制服另类日韩| 亚洲一区二区在线观看视频| 一区二区国产日产| 老司机精品视频网站| 欧美在线播放| 久久精品国产清自在天天线| 欧美自拍偷拍| 久热精品在线| 欧美国产精品v| 91久久精品国产91久久| 亚洲精品视频在线看| 亚洲精品一线二线三线无人区| 亚洲全部视频| 亚洲午夜视频在线| 亚洲狠狠婷婷| 亚洲免费精彩视频| 亚洲一区在线看| 久久国产精品99国产| 美女精品网站| 久久福利一区| 欧美激情视频免费观看| 欧美午夜一区二区| 国产午夜精品在线| 亚洲国产精品国自产拍av秋霞| 99精品欧美| 性欧美超级视频| 欧美成人一区二区三区| 99国产精品久久久久老师| 亚洲免费人成在线视频观看| 久久精品亚洲| 欧美在线一级va免费观看| 久久久久久香蕉网| 欧美区一区二区三区| 国产欧美一级| 亚洲日本欧美日韩高观看| 亚洲免费在线电影| 欧美高清视频一区二区| 在线视频免费在线观看一区二区| 久久本道综合色狠狠五月| 欧美激情影音先锋| 国语精品中文字幕| 亚洲午夜精品久久| 亚洲直播在线一区| 麻豆九一精品爱看视频在线观看免费| 亚洲欧洲综合另类| 欧美一区激情视频在线观看| 欧美日本亚洲视频| 精品成人一区二区| 亚洲欧美日韩另类| 亚洲国产一区二区精品专区| 欧美一区二区三区男人的天堂| 欧美国产精品va在线观看| 国产综合久久| 亚洲男人的天堂在线| 亚洲激情啪啪| 久久亚洲精品视频|