锘??xml version="1.0" encoding="utf-8" standalone="yes"?> In the mean time, another thread sets the condition to
鐪嬭繃鐨勫嚑綃囧仛涓瑪璁幫細騫撮緞瓚婂ぇ瓚婂簲璇ヤ繚瀹?br id="dxk9">寤鴻錛?0宀侊紝30錛呯殑璧勪駭錛屽悇縐嶆姇璧勪笉瓚呰繃70錛咃紱40宀侊紝鍌ㄨ搫40錛咃紝鎶曡祫60錛咃紱60宀侊紝鍌ㄨ搫60錛咃紝鎶曡祫40錛呫?br id="ureq0">
榪欎釜鎰忚鍩烘湰涓婂拰銆婂濂旀棌鐞嗚儲銆嬫剰瑙佷竴鑷達紝涔熷緢鍚堢悊銆?br id="g:bq">寤鴻絎竴鍙熀閲戝幓涔拌揣甯佸熀閲戙?璐у竵鍩洪噾鍐嶆庝箞涔頒篃涓嶄細鏈夋崯澶?br id="zcfw">
鎸囨暟鍩洪噾涓嶆帹鑽愶紝鍥犱負涓浗甯傚満涓嶅瑙勮寖錛堢編鍥界殑甯傚満鍩烘湰涓婃槸鏈夋晥鐨勶紝浣嗕腑鍥界殑甯傚満鎭愭曡繛鍗婃湁鏁堝競鍦洪兘涓嶆槸錛?br id="ucp:">鏂板熀閲戜笉鏄釜濂介夋嫨錛涜佺墝鍩洪噾鍏徃涓嬬殑鑰佺墝鍔叉梾鍩洪噾鎭愭曟槸涓涓ソ閫夋嫨鎴戦噰鐢ㄧ殑鏄竴嬈℃ф姇鍏ュ拰瀹氭姇緇撳悎鐨勫姙娉曘?br id="drsl">褰撴垜絎竴嬈℃妸閾惰鐨勫瓨嬈炬姇鍏ュ熀閲戠殑鏃跺欙紝鎴戝熀鏈噰鐢ㄧ殑鏄竴嬈℃ф姇鍏ワ紙瀹為檯涓婃垜鏄湪杈冪煭鐨勬椂闂村垎鎵規姇鍏ョ殑錛岃繖鏍烽檷浣庡伓鐒舵定璺屽獎鍝嶏級銆?br id="drsl0">鑰屽悗鏉ユ瘡涓湀鐨勭粨浣欏伐璧勬槸閲囩敤瀹氭姇鐨勬柟寮忔潵瀛樺吇鑰侀噾銆?br id="emxp0">
鍡紝瀹氭姇鏄緢鍚堢悊鐨勯夋嫨鍟婏紝铏界劧娉㈡鐨勮鎯戝緢澶с傘傘?br id="g:bq0">
瀹氭姇鏈澶х殑濂藉瀹為檯涓婃槸蹇冪悊涓婄殑銆?br id="f:rx">瀹氭姇灝卞彲浠ラ艱揩浣犲厠鏈嶄綘鐨勮椽濠傝繖鏄竴縐嶅己鍒舵х殑闈炲父鏈夌邯寰嬫х殑鎶曡祫鏂瑰紡錛屽埆鍘昏冭檻鑲″競鐨勬定璺岋紝涔熶笉瑕佽瘯鍥炬姄浣忚繖縐嶆定璺屻?br id="f:rx0">瑕佹敞鎰忎弗鏍肩殑鎶曡祫綰緥鎬у湪鎶曡祫涓婃槸闈炲父閲嶈鐨勩?br id="f:rx1">璇勪環涓涓熀閲戝叕鍙哥殑濂藉潖錛屽彲浠ョ湅浠栨墍鏈夌殑鍩洪噾鐨勫鉤鍧囨按騫熾?br id="axat">涓昏鍙傝冩煇瀹跺熀閲戝叕鍙告墍鏈変駭鍝佸湪鏅ㄦ槦鐨勮瘎綰э紝濡傛灉澶氭暟鏄?鏄熺殑鍩洪噾鍝佺錛岃鏄庤繖瀹跺熀閲戝叕鍙告暣浣撴按騫充笉閿欍?br id="sj3y">
鎰熻鍜宼aobao涓婃寫鍗栧宸笉澶氥傘傘?br id="g:bq1">涓涓ā鎷熺殑渚嬪瓙璇存槑瀹氭姇鏀剁泭鏈緇堝ソ浜庝竴嬈℃ф姇鍏?br id="fzj6">鑻辨枃涓畾鎶曠О涓篸ollar-cost average鏂規硶
濡傛灉浣犺闀挎湡鎶曡祫錛屾寜鐓ф櫘閬嶇殑璁や負錛屽ぇ鐩樻槸闀挎湡鍚戜笂鐨勶紝鍦ㄨ繖涓悜涓婄殑瓚嬪娍涓婃湁寰堝鐭湡鐨勬嘗鍔ㄣ傞偅瀹氭姇瀹為檯涓婂氨鏄鉤婊戜簡榪欑娉㈠姩錛屾渶鍚庡緱鍒頒竴涓鉤鍧囨晥鐩娿?br id="qpuy">瀹氭姇涓嶆槸鏈濂界殑闀挎湡鎶曡祫鏂規錛屼絾濡傛灉浣犳病鏈夐偅涔堝璧勯噾榪涜涓嬈℃ф姇璧勶紝渚嬪浣犳槸浠庢瘡涓湀鐨勬敹鍏ヤ腑鎻愬彇涓閮ㄥ垎錛屽畾鎶曞垯鏄潪甯稿ソ鐨勯夋嫨銆?br id="qpuy0">
鏃犺甯傚満鏄墰鏄唺榪樻槸鐚達紝瀹氭姇閮芥槸涓涓笉閿欑殑鍔炴硶錛岃繖鏄垜鐨勮蹇點?br id="qpuy2">鎺ㄨ崘錛?a id="p-y02" >鍩洪噾鎶曡祫鍏ラ棬緋誨垪璐存眹鎬匯愭柊鎵嬪繀璇匯?
榪欑瘒榪樻病鐪嬪畬錛岃洰緋葷粺鐨勪粙緇嶄簡鍏ラ棬錛岃繖涓互鍚庡洖鏉ラ噸璇匯傘傘?br id="g_ed">鍙﹀鎻愬埌鐨勮繖綃囧叆闂ㄨ創錛岄噸鐐圭湅浜嗛噷闈粙緇?a title="璐у竵鍩洪噾" id="py7n">璐у竵鍩洪噾鐨勯儴鍒嗐傛諱箣璐у竵鍩洪噾灝辨槸椋庨櫓灝忓洖鎶ュ皬錛屽熀鏈彲浠ョ敤鏉ヤ唬鏇垮瓨嬈劇殑涓滆タ鍚?br id="g_ed0">
鍏朵綑鐨勭炕浜嗗嚑綃囷紝鏈夋秹鍙婂埌鎶鏈?鏁板瓧鍒嗘瀽鏂歸潰鐨勶紝娌′粩緇嗘帹鏁層備竴鏂歸潰涔熸槸鐪嬩簡涓婇潰鐨勫嚑綃囧凡緇忓績鐥掔棐浜嗭紝鍛靛懙
浜庢槸鐓ф惉浜嗗嚑鏉℃剰瑙侊紝鍘繪嫑琛岃繕鏈夋櫒鏄熼涗簡閫涳紝鏈鍚庡氨閫夊畾浜?a title="鍢夊疄璐у竵" id="hi1:">鍢夊疄璐у竵 榪欏彧銆備富瑕佹槸錛?br id="agaq">
浠ュ悗鑰冭檻錛?br id="ose:0">http://www.cairographics.org/download/
鍦?a id="e0h6" >official GTK+ for Windows page錛屼笅杞芥渶鏂扮増鐨?cairo"銆?libpng"銆?zlib"
瑙e嚭libcairo-2.dll, libpng12.dll鍜寊lib1.dll錛屾斁鍒版煇鐩綍涓紙濡俤:cairobin錛夛紝灝嗚繖涓洰褰曞姞鍏ョ郴緇烶athhttp://bbs.chinaunix.net/viewthread.php?tid=1162830
甯栧瓙璁茬殑鏄疨yGTK鐨勫畨瑁咃紝鑰屼笖鑰佷簡錛屼絾鎻愬埌寰堟湁鐢ㄧ殑淇℃伅錛?br id="umi8">
windows鐗堢殑PyCairo瑕佸幓gnome鐨刦tp涓嬶紝鏈鏂扮殑1.4鐗?br id="u_.k">鍦?a title="cairo涓婚〉涓婃壘鍒扮殑PyCairo" id="bwyt">cairo涓婚〉涓婃壘鍒扮殑PyCairo 涓嬭澆鏄簮鐮佸寘錛屾湁涓猻etup.py錛屼絾瀹夎澶辮觸錛屾彁紺烘壘涓嶅埌cairohttp://www.cairographics.org/pycairo/
榪愯鍏朵腑鐨別xample璧勬枡
http://www.tortall.net/mu/wiki/CairoTutorial
http://www.cairographics.org/pycairo/
http://www.cairographics.org/manual/
gmail: daily use, just another legend
docs: AWESOME! makes doc not just doc
toolbar for Firefox: some great tools to make Firefox even greater
reader: now part of my life, to let me know what's happening around
translate: not accurate, but always help
blog search: specific tool for specific use
notebook: just not suitable for me
calendar: reminding-SMS is really useful, pity that i'm not always a scheduled person
gtalk: simple and clean. great backup for MSN, though not a replacement yet
picasa: offline tool + online holding. perfect match
blogger: really convenient when combining with google docs; really suck when being blocked by GFW!
mobile: reader, search, map... just give me more!
YouTube: not really so atractive among tons of copiers
iGoogle: not so atractive either, sorry, i prefer classic google homepage
page creator: to build a personal web page is always my dream, but...孌嬪康
desktop search: great idea, but hey guys, you can do better
code: for specialists, seems to be better than sourceforge, we'll see...
SketchUp: not really used, but really interested of this move direction
gadget and OpenSocial: these guys make Javascript so sexy!
earth: thanks for offering a free tour of world
My top 5
Search
Gmail
Docs
Talk
btw: I just feel like to speak some english after watching "how i met ur mother", anyway...
Mutex姒傚康
綰跨▼鍚屾鏈鍩烘湰鐨勬槸mutex錛坢utual exclusion鐨勭緝鍐欙級銆備竴涓簰鏂ヤ綋涓嬈″彧鍏佽涓涓嚎紼嬭闂叡浜尯銆傚綋涓涓嚎紼嬫兂瑕佽闂叡浜尯鏃訛紝棣栧厛瑕佸仛鐨勫氨鏄攣浣忥紙lock錛変簰鏂ヤ綋銆傚鏋滃叾浠栫殑 綰跨▼宸茬粡閿佷綇浜嗕簰鏂ヤ綋錛岄偅涔堝氨蹇呴』鍏堢瓑閭d釜綰跨▼灝嗕簰鏂ヤ綋瑙i攣錛岃繖鏍峰氨淇濊瘉浜嗗悓涓鏃跺埢鍙湁涓涓嚎紼嬭兘璁塊棶鍏變韓鍖哄煙銆?br id="o7hu">
Boost.Thread supplies recursive and non-recursive mutexes with exclusive ownership錛堢嫭鍗狅級 semantics, along with a shared ownership 錛堝叡浜級 (multiple-reader / single-writer) mutex.
Boost.Thread supports four basic concepts for lockable objects: Lockable, TimedLockable, Lockable鐨勫熀紜涓婂姞涓婁簡timeoutSharedLockable, TimedLockable鍩虹涓婏紝鍏佽shared ownership錛堝悓鏃朵篃鏀寔exclusive錛?br id="fd4b">
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鍩虹涓婏紝鍏佽upgradable ownership錛堝悓鏃朵篃鏀寔shared銆乪xclusive錛?br id="et:2">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().
[娉細闄ockable鐨刴utex澶栵紝鍏朵綑鐨勫悇縐嶅鏉俶utex榪橀渶瑕佹洿澶氫唬鐮佸疄璺礭
Each mutex type implements one or more of these concepts, as do the various lock types.
Lock Types
boost瀹氫箟鐨凩ock types涓篶lass template錛屼互鍚堥傜殑Lockable object浣滀負妯℃澘鍙傛暟
Mutex Typeslock_guard
鍙敮鎸佺畝鍗曠殑Lockable objectunique_locklock_guard澶嶆潅鍦細涓嶄粎鎻愪緵RAII-style鐨刲ock錛岃繕鍏佽鐢ㄦ埛鎸囧畾鏄惁鍦╟tor涓珛鍗砽ock錛屾剰鍛崇潃鍙互鎸囧畾鎺ㄨ繜lock錛坉efer acquiring the lock錛岄氳繃鎸囧畾defer_lock_t鍙傛暟錛夛紝鐩村埌鏄懼紡璋冪敤鍏秎ock()鏂規硶
榪樻敮鎸?a id="d.41" class="link" title="TimedLockable Concept">TimedLockable concept錛屽墠鎻愭槸闇瑕乴ock鐨凩ockable object鏈韓鏀寔
The member functions of boost::unique_lock are not thread-safe...[娉細榪欏彞娌$湅鎳傘傘傘俔shared_lockupgrade_lockupgrade_to_unique_lock
Mutex types瀵瑰簲浜庝箣鍓嶇殑mutex concepts錛岀洰鍓嶆湁錛?br id="pgra">mutexboost::mutex瀹炵幇浜?a id="lexp" class="link" title="Lockable Concept">Lockable concept錛屾彁渚沞xclusive-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_locktry_mutextimed_mutexrecursive_mutexrecursive_try_mutexrecursive_timed_mutexshared_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.(涓枃鍙傝?/a>)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. 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姣攃ondition_variable鏇撮氱敤錛沜ondition_variable瑕佹眰浼犵粰wait()鐨勫繀欏繪槸boost::unique_lock<boost::mutex>綾誨瀷錛?/span>condition_variable涓鑸洿浼樺寲
One-time Initialization
浠呰繍琛屼竴嬈$殑渚嬬▼
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
[娉細榪樻湭浣跨敤榪嘳
Barriers
[娉細榪樻湭浣跨敤榪嘳
鍏稿瀷鐨勫簲鐢ㄥ満鏅槸errno銆?br id="srgy">
Boost綰跨▼搴撴彁渚涗簡鏅鴻兘鎸囬拡boost::thread_specific_ptr鏉ヨ闂湰鍦板瓨鍌ㄧ嚎紼嬨傛槸璺ㄥ鉤鍙扮殑瑙e喅鏂規
http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_local_storage.html Portable thread-local storage with boost::thread_specific_ptr
Cleanup at thread exit
[娉細榪樻病鏈夊疄璺佃繃錛岀瓑鍐欒繃鐩稿簲浠g爜鍚庡啀鏉ヨˉ鍏呮枃妗
launching threads
boost::thread綾諱唬琛ㄤ竴涓彲鎵ц鐨勭嚎紼?thread of execution)銆?br id="o-fc">A new thread is launched by passing an object of a callable type that can be invoked with no parameters to the constructor.
The object is then copied into internal storage, and invoked on the newly-created thread of execution.
If you wish to construct an instance of boost::thread with a function or callable object that requires arguments to be supplied, this can be done using boost::bind.
錛坱hread non-copiable, but movable; object that used to created a thread must callable, if not, use boost::ref錛?span id="fw.2">
Joining and detaching
褰撲唬琛ㄤ竴涓彲鎵ц鐨勭嚎紼?thread of execution)鐨刡oost::thread瀵硅薄琚攢姣佹椂錛岃繖涓嚎紼嬩究鍚屾椂琚?span id="ihma">detached. Detached鐨勭嚎紼嬪皢緇х畫榪愯鐩村埌綰跨▼緇堟銆?br id="w9kr"> 涔熷彲浠ユ樉寮忚皟鐢?explicitly)涓涓猙oost::thread瀵硅薄鐨刣etach()鏂規硶錛岃繖鏃惰繖涓嚎紼嬬洿鎺ヨdetach錛岃岃繖涓猙oost::thread瀵硅薄璁蹭笉鍐嶄唬琛╰hread of execution錛岃屾寚Not-a-Thread
join()鐢ㄤ簬絳夊緟涓涓嚎紼嬬粨鏉熴?br id="ea24">(timed_join())
Interruption
璋冪敤boost::thread瀵硅薄鐨?span id="fvio">interrupt()鏂規硶錛屽彲浠ヤ腑鏂叾瀵瑰簲鐨勭嚎紼嬨?br id="aa5i"> When the interrupted thread next executes one of the specified interruption points (or if it is currently blocked whilst executing one) with interruption enabled, then a boost::thread_interrupted exception will be thrown in the interrupted thread. If not caught, this will cause the execution of the interrupted thread to terminate. As with any other exception, the stack will be unwound, and destructors for objects of automatic storage duration will be executed.
(boost::this_thread::disable_interruption, Predefined Interruption Points)
Thread IDs
姣忎竴涓繍琛屼腑鐨則hread閮芥湁涓涓敮涓鐨刬d鍊箋?br id="neiu">璋冪敤瀵瑰簲鐨?a id="b9db" class="link" title="Class thread">boost::thread瀵硅薄鐨?/code>鏂規硶銆?br id="h8n3">get_id()鏂規硶錛屾垨鑰呭湪榪愯鐨則hread涓皟鐢?code id="tu3j" class="computeroutput">boost::this_thread::get_id()
Namespace this_thread
this_thread涓嬪寘鍚殑鏄湪姝e湪榪愯鐨勭嚎紼嬪唴閮紝鎵鑳借繘琛岀殑綰跨▼鎿嶄綔錛屽寘鎷笂闈㈡彁鍒扮殑get_id()鏂規硶
http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#thread.thread_management.this_thread
Thread Group
thread_group class provides for a collection of threads that are related in some fashion.
New threads can be added to the group with add_thread and create_thread member functions.
thread_group is not copyable or movable.
鏂扮増boost鏂囨。涓凡緇忔病鏈夎繖涓绔犱簡
http://docs.google.com/Doc?id=dgnd783p_142fgzzpbcv
http://docs.google.com/Doc?id=dgnd783p_146crx42gn9
http://docs.google.com/Doc?id=dgnd783p_147hjchrgf8
鍙傝冿細
涓涓猚/pthread鐨則hread鏁欑▼錛屾湁涓浜涘吀鍨嬩緥瀛愮殑浠g爜銆佺畻娉曡鏄?
C++ Boost Thread 緙栫▼鎸囧崡錛堜腑鏂囩増錛?br id="uhdt">http://www.ddj.com/cpp/184401518
鑻辨枃鍘熺増
WARNING錛歄ut-of-Date錛?002騫寸殑錛? 鍙兘鍙傝冪敤
鑻辨枃鐨勪竴綃嘼oost.thread璇存槑錛岄噷闈㈡湁boost::thread鐨勭畝鍗曚緥瀛愶紝鍏朵腑涓涓嬌鐢ㄤ簡condition
WARNING錛歄ut-of-Date! 鍙兘鍙傝冪敤
Code錛?br id="l44p">
鐒惰宑sdn涓嶈鍏ㄦ枃杈撳嚭rss榪欎竴鐐瑰氨瓚寵凍鎶婃垜閫艱蛋
鐜板湪寮濮嬭瘯璇曠湅榪欓噷錛屾劅瑙夎繖閲岃兘婊¤凍鎴戝ぇ閮ㄥ垎瑕佹眰錛屼絾鎰胯繖嬈″氨鑳藉交搴曞畾涓嬫潵浜嗐傘傘?br>