﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-web2.0 - research2.0</title><link>http://www.cppblog.com/frank28/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 14 Apr 2026 23:08:03 GMT</lastBuildDate><pubDate>Tue, 14 Apr 2026 23:08:03 GMT</pubDate><ttl>60</ttl><item><title>[基金] 入市了</title><link>http://www.cppblog.com/frank28/archive/2008/08/13/58739.html</link><dc:creator>frank28_nfls</dc:creator><author>frank28_nfls</author><pubDate>Wed, 13 Aug 2008 09:47:00 GMT</pubDate><guid>http://www.cppblog.com/frank28/archive/2008/08/13/58739.html</guid><wfw:comment>http://www.cppblog.com/frank28/comments/58739.html</wfw:comment><comments>http://www.cppblog.com/frank28/archive/2008/08/13/58739.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/frank28/comments/commentRss/58739.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/frank28/services/trackbacks/58739.html</trackback:ping><description><![CDATA[             一直收藏着<a title="laok的blog" href="http://laok2.blog.sohu.com/" id="gf2h">laok的blog</a> ，讲基金的blog，还知道他有一本《我的投资观和实践》，想着有一天要买基金了就好好研究一下的。<br id="bozf">今天没事的时候翻了几篇，看着看着有了感觉，最后忍不住就手痒去招行实践了一把，于是我就这么也成为了“基民”。<br id="cqtj"><br id="cqtj0">看过的几篇做个笔记：<br id="acel"><ul id="acel0"><li id="acel1"><b id="anfz"><a title="1，该把多少存款用来投资？" href="http://laok2.blog.sohu.com/32297934.html" id="gano">1，该把多少存款用来投资？</a></b> <br id="mgfa"><blockquote id="ureq">年龄越大越应该保守<br id="dxk9">建议：30岁，30％的资产，各种投资不超过70％；40岁，储蓄40％，投资60％；60岁，储蓄60％，投资40％。<br id="ureq0"></blockquote>这个意见基本上和《奔奔族理财》意见一致，也很合理。<br id="g:bq"><br id="ureq1"></li><li id="ureq2"><b id="anfz0"><a title="3， 第一只基金买甚么？" href="http://laok2.blog.sohu.com/32298617.html" id="c9zx">3， 第一只基金买甚么？</a></b> <br id="ureq3"><blockquote id="bksh">建议第一只基金去买货币基金。 货币基金再怎么买也不会有损失<br id="zcfw"><ul id="cy6_"><li id="cy6_0">首先取决于你的风险承受能力和你准备投资的年限，先要确定投资甚么基金品种；</li><li id="cy6_1">再确定是哪个公司的哪种基金。选择晨星评级至少4星以上的；</li><li id="emxp">不能以短时间论英雄；三个月，甚至半年以内的排位我认为没有任何意义。</li></ul>指数基金不推荐，因为中国市场不够规范（美国的市场基本上是有效的，但中国的市场恐怕连半有效市场都不是）<br id="ucp:">新基金不是个好选择；老牌基金公司下的老牌劲旅基金恐怕是一个好选择<br id="bksh0"></blockquote><br id="bksh1"></li><li id="bksh2"><b id="anfz1"><a title="5，关于基金定投" href="http://laok2.blog.sohu.com/32298976.html" id="m-j_">5，关于基金定投</a></b> <br id="x4bd"><blockquote id="kwir">我采用的是一次性投入和定投结合的办法。<br id="drsl">当我第一次把银行的存款投入基金的时候，我基本采用的是一次性投入（实际上我是在较短的时间分批投入的，这样降低偶然涨跌影响）。<br id="drsl0">而后来每个月的结余工资是采用定投的方式来存养老金。<br id="emxp0"><br id="i2-2">定投最大的好处实际上是心理上的。<br id="f:rx">定投就可以逼迫你克服你的贪婪。这是一种强制性的非常有纪律性的投资方式，别去考虑股市的涨跌，也不要试图抓住这种涨跌。<br id="f:rx0">要注意严格的投资纪律性在投资上是非常重要的。<br id="f:rx1"></blockquote>嗯，定投是很合理的选择啊，虽然波段的诱惑很大。。。<br id="g:bq0"><br id="f:rx2"></li><li id="f:rx3"><b id="anfz2"><a title="13，我为什么选择广发和上投" href="http://laok2.blog.sohu.com/32305524.html" id="dn:b">13，我为什么选择广发和上投</a></b> <br id="wj8_"><blockquote id="p-y0">评价一个基金公司的好坏，可以看他所有的基金的平均水平。<br id="axat">主要参考某家基金公司所有产品在晨星的评级，如果多数是5星的基金品种，说明这家基金公司整体水平不错。<br id="sj3y"></blockquote>感觉和taobao上挑卖家差不多。。。<br id="g:bq1"><br id="sj3y0"></li><li id="sj3y1"><b id="anfz3"><a title="31，再说定投" href="http://laok2.blog.sohu.com/32331154.html" id="xanr">31，再说定投</a></b> <br id="plpg"><blockquote id="p-y00">一个模拟的例子说明定投收益最终好于一次性投入<br id="fzj6">英文中定投称为dollar-cost average方法<br id="vks-">如果你要长期投资，按照普遍的认为，大盘是长期向上的，在这个向上的趋势上有很多短期的波动。那定投实际上就是平滑了这种波动，最后得到一个平均效益。<br id="qpuy">定投不是最好的长期投资方案，但如果你没有那么多资金进行一次性投资，例如你是从每个月的收入中提取一部分，定投则是非常好的选择。<br id="qpuy0"><br id="qpuy1">无论市场是牛是熊还是猴，定投都是一个不错的办法，这是我的观念。<br id="qpuy2"></blockquote><br id="qpuy3"></li><li id="qpuy4"><b id="anfz4"><a title="15，给基金新手的一些建议" href="http://laok2.blog.sohu.com/32307295.html" id="u2xy">15，给基金新手的一些建议</a></b> <br id="bfjh"><blockquote id="p-y01">推荐：<a id="p-y02" href="http://club.money.business.sohu.com/r-shgame-46847-0-50-0.html">基金投资入门系列贴汇总【新手必读】 </a><br id="p-y03"></blockquote>这篇还没看完，蛮系统的介绍了入门，这个以后回来重读。。。<br id="g_ed">另外提到的这篇入门贴，重点看了里面介绍<a title="货币基金" href="http://club.money.business.sohu.com/r-shgame-29543-0-43-0.html" id="py7n">货币基金</a>的部分。总之货币基金就是风险小回报小，基本可以用来代替存款的东西吧<br id="g_ed0"></li></ul><br id="krkk"><br id="krkk0">其余的翻了几篇，有涉及到技术/数字分析方面的，没仔细推敲。一方面也是看了上面的几篇已经心痒痒了，呵呵<br id="hfzr"><br id="krkk1">于是照搬了几条意见，去招行还有晨星逛了逛，最后就选定了<a title="嘉实货币" href="http://www.caibangzi.com/monetary_fund/070008" id="hi1:">嘉实货币</a> 这只。主要是：<br id="agaq"><ol id="agaq0"><li id="agaq1">肯定选一只货币基金；另外现在股票市场还太混乱，看不清，感觉货币基金也稳妥些。</li><li id="zn4g">投入不多，不超过所有资金的1/5<br id="zn4g0"></li><li id="agaq2">看了嘉实的其他基金品种，蛮多在晨星达到了5星的评价</li><li id="j._6">不是收益最高的，但晨星对它去年的评价也不错，而且查看了近几周排名，都排在货币基金的第一位。</li><li id="ypjo">晨星对嘉实货币去年收益的排名是第二，第一是中信现金优势，不过招行不能买；中信现金优势似乎也不错，值得关注</li></ol><br id="ose:">以后考虑：<br id="ose:0"><ol id="ose:1"><li id="ose:2">再仔细研究一些基金知识，同时切身体会一下操作基金的感觉</li><li id="ose:3">重点考虑定投一到两只股票型基金，毕竟现在的股市那么低，反弹空间诱人啊～</li><li id="jcqu"><a title="财帮子网" href="http://www.caibangzi.com/" id="jxav">财帮子网</a>看上去还不错，或者要找一个同类的工具型网站，最好也能包括股市投资记录的</li></ol><br id="ose:5"><br id="ose:6"><br id="fuo8"><img src ="http://www.cppblog.com/frank28/aggbug/58739.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/frank28/" target="_blank">frank28_nfls</a> 2008-08-13 17:47 <a href="http://www.cppblog.com/frank28/archive/2008/08/13/58739.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[PyCairo]安装/资料收集</title><link>http://www.cppblog.com/frank28/archive/2008/07/30/57520.html</link><dc:creator>frank28_nfls</dc:creator><author>frank28_nfls</author><pubDate>Wed, 30 Jul 2008 08:12:00 GMT</pubDate><guid>http://www.cppblog.com/frank28/archive/2008/07/30/57520.html</guid><wfw:comment>http://www.cppblog.com/frank28/comments/57520.html</wfw:comment><comments>http://www.cppblog.com/frank28/archive/2008/07/30/57520.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/frank28/comments/commentRss/57520.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/frank28/services/trackbacks/57520.html</trackback:ping><description><![CDATA[<h2 id="woym">安装</h2><ol id="s7lu"><li id="h2.f1">安装cairo的runtime库<br id="h2.f"><br id="s7lu1"><blockquote id="is.1"><a title="http://www.cairographics.org/download/" href="http://www.cairographics.org/download/" id="kjuo">http://www.cairographics.org/download/</a> <br id="is.10"><br id="yz06">在<a id="e0h6" href="http://www.gtk.org/download-windows.html">official GTK+ for Windows page</a>，下载最新版的"cairo"、"libpng"、"zlib"<br id="is.11">解出libcairo-2.dll, libpng12.dll和zlib1.dll，放到某目录中（如d:cairobin），将这个目录加入系统Path</blockquote></li><li id="is.12">安装python2.5<br id="w_6."><br id="w_6.0"></li><li id="w_6.1">安装PyCairo<br id="u72w"><blockquote id="nz-g"><a title="http://bbs.chinaunix.net/viewthread.php?tid=1162830" href="http://bbs.chinaunix.net/viewthread.php?tid=1162830" id="oa2n">http://bbs.chinaunix.net/viewthread.php?tid=1162830</a> <br id="u72w0">帖子讲的是PyGTK的安装，而且老了，但提到很有用的信息：<br id="umi8"><br id="umi80">windows版的PyCairo要去<a title="gnome的ftp" href="http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/" id="f4yr">gnome的ftp</a>下，最新的1.4版<br id="u_.k">在<a title="cairo主页上找到的PyCairo" href="http://www.cairographics.org/pycairo/" id="bwyt">cairo主页上找到的PyCairo</a> 下载是源码包，有个setup.py，但安装失败，提示找不到cairo<br id="qhuu"></blockquote><br id="qhuu0"></li><li id="qhuu1">测试<br id="qhuu2"><blockquote id="zo40"><a title="http://www.cairographics.org/pycairo/" href="http://www.cairographics.org/pycairo/" id="i..n">http://www.cairographics.org/pycairo/</a> <br id="i:bs">运行其中的example<br id="i:bs0"></blockquote><br id="i:bs1"></li></ol><h2 id="zo400">资料</h2><ol id="t2m6"><li id="t2m60"><b id="nelk">Cairo Tutorial for Python Programmers</b><br id="t2m61"><a title="http://www.tortall.net/mu/wiki/CairoTutorial" href="http://www.tortall.net/mu/wiki/CairoTutorial" id="ystr">http://www.tortall.net/mu/wiki/CairoTutorial</a> <br id="t2m62"></li><li id="t2m63">PyCairo主页<br id="e3ka"><a title="http://www.cairographics.org/pycairo/" href="http://www.cairographics.org/pycairo/" id="n4mt">http://www.cairographics.org/pycairo/</a> <br id="e3ka0"></li><li id="e3ka1">cairo C documentation<br id="nz-g0"><a title="http://www.cairographics.org/manual/" href="http://www.cairographics.org/manual/" id="w5-s">http://www.cairographics.org/manual/</a> <br id="e3ka2"></li></ol><img src ="http://www.cppblog.com/frank28/aggbug/57520.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/frank28/" target="_blank">frank28_nfls</a> 2008-07-30 16:12 <a href="http://www.cppblog.com/frank28/archive/2008/07/30/57520.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[google]How I feel about Google Services</title><link>http://www.cppblog.com/frank28/archive/2008/04/29/google_services_review.html</link><dc:creator>frank28_nfls</dc:creator><author>frank28_nfls</author><pubDate>Tue, 29 Apr 2008 08:49:00 GMT</pubDate><guid>http://www.cppblog.com/frank28/archive/2008/04/29/google_services_review.html</guid><wfw:comment>http://www.cppblog.com/frank28/comments/48463.html</wfw:comment><comments>http://www.cppblog.com/frank28/archive/2008/04/29/google_services_review.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/frank28/comments/commentRss/48463.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/frank28/services/trackbacks/48463.html</trackback:ping><description><![CDATA[<a title="search" href="http://www.google.com/" id="vlsw">search</a>: this is where all story begins<br><a title="gmail" href="http://gmail.com/" id="nx4b">gmail</a>: daily use, just another legend<br><a title="docs" href="http://docs.google.com/" id="cpng">docs</a>: AWESOME! makes doc not just doc<br><a title="toolbar for firefox" href="http://www.google.com/tools/firefox/toolbar/FT3/intl/en/index.html" id="qjzj">toolbar for Firefox</a>: some great tools to make Firefox even greater<br><a title="reader" href="http://www.google.com/reader/" id="u6k6">reader</a>: now part of my life, to let me know what's happening around<br><a title="translate" href="http://www.google.com/language_tools?hl=en" id="nz2f">translate</a>: not accurate, but always help<br><a title="blog search" href="http://www.google.com/blogsearch?hl=en" id="x3n5">blog search</a>: specific tool for specific use<br><a title="notebook" href="http://www.google.com/notebook/?hl=en" id="w18g">notebook</a>: just not suitable for me<br><a title="calendar" href="http://www.google.com/calendar/">calendar</a>: reminding-SMS is really useful, pity that i'm not always a scheduled person<br><a title="gtalk" href="http://www.google.com/talk/" id="zdyt">gtalk</a>: simple and clean. great backup for MSN, though not a replacement yet <br><a title="picasa" href="http://picasa.google.com/#utm_source=en-all-more&amp;utm_campaign=en-pic&amp;utm_medium=et" id="ep22">picasa</a>: offline tool + online holding. perfect match<br><a title="blogger" href="http://www.blogger.com/start?hl=en" id="vizg">blogger</a>: really convenient when combining with google docs; really suck when being blocked by GFW!<br><a title="mobile" href="http://www.google.com/mobile/" id="mzb9">mobile</a>: reader, search, map... just give me more!<br><a title="YouTube" href="http://www.youtube.com/" id="lr_n">YouTube</a>: not really so atractive among tons of copiers<br><a title="iGoogle" href="http://www.google.com/ig?source=mpues&amp;hl=en" id="ck2h">iGoogle</a>: not so atractive either, sorry, i prefer classic google homepage<br><a title="page creator" href="http://www.google.com/url?sa=t&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fpages.google.com%2F&amp;ei=hjS4R5qDBIyy6wOYvo2tDQ&amp;usg=AFQjCNFH8adsA2hkzCqPNs3LoBIvq15aWQ&amp;sig2=9q3GCes74QWcbzhpO7bMrA" id="h8ab">page creator</a>: to build a personal web page is always my dream, but...残念<br><a title="desktop search" href="http://desktop.google.com/?utm_source=en-et-more&amp;utm_medium=et&amp;utm_campaign=en" id="p4u9">desktop search</a>: great idea, but hey guys, you can do better<br><a title="code" href="http://code.google.com/" id="cbha">code</a>: for specialists, seems to be better than sourceforge, we'll see...<br><a title="SketchUp" href="http://sketchup.google.com/" id="dy3m">SketchUp</a>: not really used, but really interested of this move direction<br><a title="gadget" href="http://www.google.com/ig/directory?synd=open" id="ixq4">gadget</a> and <a title="OpenSocial" href="http://code.google.com/apis/opensocial/" id="ie6n">OpenSocial</a>: these guys make Javascript so sexy!<br><a title="earth" href="http://earth.google.com/" id="odct">earth</a>: thanks for offering a free tour of world<br><br><br><font size="3"><strong><em>My top 5</em></strong></font><br><br><a href="http://www.google.com/"><img src="http://www.google.com/options/icons/coop.gif" alt="Search" border="0" height="35" vspace="1" width="35"></a><a href="http://www.google.com/">Search</a>    <a href="http://mail.google.com/mail?hl=en&amp;utm_source=en-et-more&amp;utm_medium=et&amp;utm_campaign=en"><img src="http://www.google.com/options/icons/gmail.gif" alt="Gmail" border="0" height="35" vspace="1" width="35"></a><a href="http://mail.google.com/mail?hl=en&amp;utm_source=en-et-more&amp;utm_medium=et&amp;utm_campaign=en">Gmail</a>    <a href="https://www.google.com/accounts/ServiceLogin?service=writely&amp;hl=en&amp;passive=true&amp;continue=http%3A%2F%2Fdocs.google.com%2F&amp;ltmpl=WR_tmp_2_lfty&amp;nui=1&amp;utm_campaign=en&amp;utm_source=en-et-more&amp;utm_medium=more"><img src="http://www.google.com/options/icons/dns.gif" alt="Docs" border="0" height="35" vspace="1" width="35"></a><a href="https://www.google.com/accounts/ServiceLogin?service=writely&amp;hl=en&amp;passive=true&amp;continue=http%3A%2F%2Fdocs.google.com%2F&amp;ltmpl=WR_tmp_2_lfty&amp;nui=1&amp;utm_campaign=en&amp;utm_source=en-et-more&amp;utm_medium=more">Docs</a>     <a href="http://reader.google.com/"><img src="http://www.google.com/reader/ui/2426084610-reader-logo-en.gif" alt="Reader" border="0" height="28" vspace="1" width="133"></a>    <a href="http://www.google.com/talk/"><img src="http://www.google.com/options/icons/talk.gif" alt="Talk" border="0" height="35" vspace="1" width="35"></a><a href="http://www.google.com/talk/">Talk</a> <br><br><br><br>btw: I just feel like to speak some english after watching "how i met ur mother", anyway...<br><br>
<div style="margin: 5px; background: yellow none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-family: arial; font-size: 13px;" id="dictdiv"></div>
<div id="dictaudio"></div><img src ="http://www.cppblog.com/frank28/aggbug/48463.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/frank28/" target="_blank">frank28_nfls</a> 2008-04-29 16:49 <a href="http://www.cppblog.com/frank28/archive/2008/04/29/google_services_review.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[boost.thread] Synchronization 同步</title><link>http://www.cppblog.com/frank28/archive/2008/04/29/48431.html</link><dc:creator>frank28_nfls</dc:creator><author>frank28_nfls</author><pubDate>Tue, 29 Apr 2008 06:28:00 GMT</pubDate><guid>http://www.cppblog.com/frank28/archive/2008/04/29/48431.html</guid><wfw:comment>http://www.cppblog.com/frank28/comments/48431.html</wfw:comment><comments>http://www.cppblog.com/frank28/archive/2008/04/29/48431.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/frank28/comments/commentRss/48431.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/frank28/services/trackbacks/48431.html</trackback:ping><description><![CDATA[                        <a title="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html" id="incn">http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html</a> <br id="kpla"><br id="g5js"><font id="qfg4" size="4"><b id="kk7o">Mutex概念</b></font><br id="f6nr">线程同步最基本的是mutex（mutual exclusion的缩写）。一个互斥体一次只允许一个线程访问共享区。当一个线程想要访问共享区时，首先要做的就是锁住（lock）互斥体。如果其他的 线程已经锁住了互斥体，那么就必须先等那个线程将互斥体解锁，这样就保证了同一时刻只有一个线程能访问共享区域。<br id="o7hu"><br id="o1h4">Boost.Thread supplies <span id="bnn6"><b id="l.nr">recursive</b></span> and <span id="odrc"><b id="re33">non-recursive</b></span>         mutexes with <span id="k9dm"><b id="fs_2">exclusive ownership</b></span>（独占） semantics, along with a <span id="it.o"><b id="uw3e">shared ownership</b></span>        （共享） (multiple-reader / single-writer) mutex.<br id="lpzp">Boost.Thread supports four basic concepts         for lockable objects: <br id="nutm"><br id="z3cv"><a id="id:h" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable" title="Lockable Concept"><code id="qw_5" class="computeroutput"><span id="wi7d" class="identifier">Lockable</span></code></a>, <br id="hmz0"><div id="f2j1" style="margin-left: 40px;">exclusive           ownership<br id="w_ow"></div><a id="pto-" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.timed_lockable" title="TimedLockable Concept"><code id="vefq" class="computeroutput"><span id="p145" class="identifier">TimedLockable</span></code></a>, <br id="mx45"><div id="y7nv" style="margin-left: 40px;"><a id="id:h" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable" title="Lockable Concept"><code id="qw_5" class="computeroutput"><span id="wi7d" class="identifier">Lockable</span></code></a>的基础上加上了timeout<br id="fq83"></div><a id="trxj" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.shared_lockable" title="SharedLockable Concept"><code id="cn9n" class="computeroutput"><span id="zg31" class="identifier">SharedLockable</span></code></a>, <br id="e35t"><div id="pad4" style="margin-left: 40px;"><a id="pto-" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.timed_lockable" title="TimedLockable Concept"><code id="vefq" class="computeroutput"><span id="p145" class="identifier">TimedLockable</span></code></a>基础上，允许shared ownership（同时也支持exclusive）<br id="fd4b"></div><div id="m77k" style="margin-left: 40px;">This is the standard multiple-reader / single-write           model: <br id="izhw">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.</div><a id="hbf4" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.upgrade_lockable" title="UpgradeLockable Concept"><code id="seuk" class="computeroutput"><span id="svpx" class="identifier">UpgradeLockable</span></code></a>, <br id="linz"><div id="uw3h" style="margin-left: 40px;"><a id="trxj" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.shared_lockable" title="SharedLockable Concept"><code id="cn9n" class="computeroutput"><span id="zg31" class="identifier">SharedLockable</span></code></a>基础上，允许upgradable ownership（同时也支持shared、exclusive）<br id="et:2"></div><div id="turs" style="margin-left: 40px;">This           is an extension to the multiple-reader / single-write model provided by           the <a id="j2y6" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.shared_lockable" title="SharedLockable Concept"><code id="dq_:" class="computeroutput"><span id="zedb" class="identifier">SharedLockable</span></code> concept</a>: <br id="ta4q">a single           thread may have <span id="k0c7" class="emphasis"><i id="w4qp">upgradable ownership</i></span> at the same time           as others have <span id="jnpx" class="emphasis"><i id="gca_">shared ownership</i></span>. The thread with           <span id="s:os" class="emphasis"><i id="c9b2">upgradable ownership</i></span> may at any time attempt to upgrade           that ownership to <span id="v4t6" class="emphasis"><i id="f8:x">exclusive ownership</i></span>. If no other           threads have shared ownership, the upgrade is completed immediately, and           the thread now has <span id="j2_n" class="emphasis"><i id="xwzv">exclusive ownership</i></span>, which must           be relinquished by a call to <a id="g.ls" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable.unlock" title="void unlock()"><code id="icks" class="computeroutput"><span id="utkk" class="identifier">unlock</span><span id="e:y1" class="special">()</span></code></a>,           just as if it had been acquired by a call to <a id="huy5" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable.lock" title="void lock()"><code id="br90" class="computeroutput"><span id="ulp7" class="identifier">lock</span><span id="a3t_" class="special">()</span></code></a>.<br id="kzu-"></div><br id="d9rm">[注：除Lockable的mutex外，其余的各种复杂mutex还需要更多代码实践]<br id="mcfc"><br id="z:5r"> Each mutex type         implements one or more of these concepts, as do the <span id="m0sy"><b id="e9yg">various lock types</b></span>.<br id="yv1."><br id="q-_u"><font id="bj5z" size="4"><span id="qwm."><b id="j_8x">Lock Types</b></span></font><br id="h.d-">boost定义的Lock types为class template，以合适的Lockable object作为模板参数<br id="m.-0"><div id="bf:y" class="toc"><dl id="ukhd"><dt id="veim"><span id="d.z4" class="section"><a id="h.-0" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.locks.lock_guard"><code id="wjkg" class="computeroutput"><span id="ylxq" class="identifier">lock_guard</span></code></a></span></dt><dd id="xpt.">RAII-style的简单lock，在ctor中lock，在dtor中unlock<br id="yegb">只支持简单的<a id="id:h" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable" title="Lockable Concept"><code id="qw_5" class="computeroutput"><span id="wi7d" class="identifier">Lockable</span></code></a> object<br id="r8l6"></dd><dt id="c8el"><span id="zphg" class="section"><a id="v2tk" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.locks.unique_lock"><code id="hlld" class="computeroutput"><span id="gy8z" class="identifier">unique_lock</span></code></a></span></dt><dd id="x8t5">比<a id="h.-0" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.locks.lock_guard"><code id="wjkg" class="computeroutput"><span id="ylxq" class="identifier">lock_guard</span></code></a>复杂在：不仅提供RAII-style的lock，还允许用户指定是否在ctor中立即lock，意味着可以指定推迟lock（defer           acquiring the lock，通过指定<span id="jfmb" class="identifier">defer_lock_t</span>参数），直到显式调用其lock()方法<br id="gorz">还支持<a id="d.41" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.timed_lockable" title="TimedLockable Concept"><code id="d4al" class="computeroutput"><span id="a-1m" class="identifier">TimedLockable</span></code> concept</a>，前提是需要lock的Lockable object本身支持<br id="s::d">           The member functions of <a id="ny06" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.locks.unique_lock" title="Class template unique_lock"><code id="j-j_" class="computeroutput"><span id="o5b0" class="identifier">boost</span><span id="n-uu" class="special">::</span><span id="me5t" class="identifier">unique_lock</span></code></a> are not thread-safe...[注：这句没看懂。。。]</dd><dt id="zlii"><br id="gf4_"></dt><dt id="ny8o"><span id="cx8t" class="section"><a id="ioha" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.locks.shared_lock"><code id="mn4q" class="computeroutput"><span id="yhxb" class="identifier">shared_lock</span></code></a></span></dt><dt id="axa2"><span id="kuwo" class="section"><a id="qvj:" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.locks.upgrade_lock"><code id="ke-k" class="computeroutput"><span id="ump:" class="identifier">upgrade_lock</span></code></a></span></dt><dt id="zaa:"><span id="o_ng" class="section"><a id="l1tu" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.locks.upgrade_to_unique_lock"><code id="jfx3" class="computeroutput"><span id="klmr" class="identifier">upgrade_to_unique_lock</span></code></a></span></dt><dd id="o_pw"><br id="c3qf"></dd><dt id="zaa:"><span id="o_ng" class="section"><a id="l1tu" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.locks.upgrade_to_unique_lock"></a></span>[注：目前只用过unique_lock。后面几种对应于不同需求的lock，从名字就可以直观看出功能，还未试验，直接参考api]</dt></dl><font id="yqmc" size="4"><b id="w9_x">Mutex Types</b></font><br id="amid">Mutex types对应于之前的mutex concepts，目前有：<br id="pgra"><div id="xqev" class="toc"><dl id="x4le"><dt id="h_12"><span id="h_ld" class="section"><a id="a750" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.mutex"> Class <code id="a5hg" class="computeroutput"><span id="at-i" class="identifier">mutex</span></code></a></span></dt><dd id="i1jc"><a id="cvfa" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.mutex" title="Class mutex"><code id="v3-o" class="computeroutput"><span id="ikw0" class="identifier">boost</span><span id="h-pd" class="special">::</span><span id="pohl" class="identifier">mutex</span></code></a>实现了<a id="lexp" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable" title="Lockable Concept"><code id="hifz" class="computeroutput"><span id="rix-" class="identifier">Lockable</span></code> concept</a>，提供exclusive-ownership mutex. <br id="hugi">At most one thread can own the lock on a given           instance of <a id="vm2b" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.mutex" title="Class mutex"><code id="trwu" class="computeroutput"><span id="t-n3" class="identifier">boost</span><span id="ml-8" class="special">::</span><span id="giqb" class="identifier">mutex</span></code></a> at any time. <br id="tkwx">Multiple concurrent           calls to <a id="q4j9" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable.lock" title="void lock()"><code id="o0-l" class="computeroutput"><span id="te3o" class="identifier">lock</span><span id="lu31" class="special">()</span></code></a>,           <a id="ggmg" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable.try_lock" title="bool try_lock()"><code id="ha_f" class="computeroutput"><span id="ncxw" class="identifier">try_lock</span><span id="zn9n" class="special">()</span></code></a>           and <a id="ar8b" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.lockable.unlock" title="void unlock()"><code id="l-ni" class="computeroutput"><span id="ffor" class="identifier">unlock</span><span id="muhb" class="special">()</span></code></a>           shall be permitted.<br id="mvha"><br id="z3x8"><span id="dyvf"><b id="re-l">typedef unique_lock<mutex> mutex::scoped_lock;</b></span></dd><dt id="c5wy"><br id="wcy9"></dt><dt id="z8rk"><span id="h.06" class="section"><a id="i0ow" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.try_mutex"> Typedef         <code id="a6-y" class="computeroutput"><span id="ehxe" class="identifier">try_mutex</span></code></a></span></dt><dt id="rwkb"><span id="td68" class="section"><a id="zn26" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.timed_mutex"> Class         <code id="pb9o" class="computeroutput"><span id="il9:" class="identifier">timed_mutex</span></code></a></span></dt><dt id="w9_r"><span id="bnpa" class="section"><a id="ka81" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.recursive_mutex">         Class <code id="gml:" class="computeroutput"><span id="ztkp" class="identifier">recursive_mutex</span></code></a></span></dt><dt id="ljfp"><span id="e053" class="section"><a id="x5rn" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.recursive_try_mutex">         Typedef <code id="azmp" class="computeroutput"><span id="g-wt" class="identifier">recursive_try_mutex</span></code></a></span></dt><dt id="prx2"><span id="sj6x" class="section"><a id="d-8b" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.recursive_timed_mutex">         Class <code id="xost" class="computeroutput"><span id="dd01" class="identifier">recursive_timed_mutex</span></code></a></span></dt><dt id="jsm1"><span id="itmv" class="section"><a id="zw0p" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.shared_mutex"> Class         <code id="bguz" class="computeroutput"><span id="mq8k" class="identifier">shared_mutex</span></code></a></span></dt></dl></div>适用于不同需求<br id="g0tp"><br id="ku-x"><br id="jin:"><font id="pslr" size="4"><a title="Condition Variables" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.condvar_ref" id="q8s8"><b id="cliy">Condition Variables</b></a> </font><br id="eh5w">The general usage pattern         is that one thread locks a mutex and then calls <code id="tsmo" class="computeroutput"><span id="sw1g" class="identifier">wait</span></code>         on an instance of <code id="g-pt" class="computeroutput"><span id="m:8y" class="identifier">condition_variable</span></code>         or <code id="r0-q" class="computeroutput"><span id="e:_q" class="identifier">condition_variable_any</span></code>.         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 <code id="gkfp" class="computeroutput"><span id="rq.d" class="identifier">wait</span></code>         again to resume waiting.(<a title="中文参考" href="http://www.stlchina.org/twiki/bin/view.pl/Main/BoostThread#3%20%CC%F5%BC%FE%B1%E4%C1%BF" id="p3gv">中文参考</a>)<br id="o7.:"><br id="ncd2"><code id="f0hn" class="computeroutput"><span id="i.t:" class="identifier">lock</span></code> is passed         to <code id="c3pi" class="computeroutput"><span id="w6ic" class="identifier"><b id="uhn7">wait()</b></span></code>； <code id="rnbf" class="computeroutput"><span id="s4mr" class="identifier"><b id="d.9l">wait()</b></span></code>         will <span id="qu1r"><b id="pgpr">atomically</b></span> add the thread to the set of threads waiting on the condition         variable, and <span id="yaj7"><b id="j:7c">unlock the mutex</b></span>. When the thread is woken, the mutex will         be <span id="m4z5"><b id="qx1l">locked again</b></span> before the call to <code id="za8b" class="computeroutput"><span id="x:9b" class="identifier">wait</span></code>         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.        <p id="n:3p">         In the mean time, another thread sets the condition to <code id="jzum" class="computeroutput"><span id="nk:_" class="keyword">true</span></code>,         and then calls either <code id="s-2r" class="computeroutput"><span id="je91" class="identifier"><b id="rq7:">notify_one()</b></span></code>         or <code id="n6xi" class="computeroutput"><span id="nitp" class="identifier"><b id="cvg7">notify_all()</b></span></code> on the condition         variable to wake one waiting thread or all the waiting threads respectively.       </p><br id="mav:">condition_variable_any比condition_variable更通用；condition_variable要求传给wait()的必须是<code id="p82:" class="computeroutput"><span id="h13o" class="identifier">boost</span><span id="p35i" class="special">::</span><span id="j1gi" class="identifier">unique_lock</span><span id="okzk" class="special"><</span><span id="w5wa" class="identifier">boost</span><span id="n-:n" class="special">::</span><span id="pi2q" class="identifier">mutex</span><span id="n52o" class="special">>类型；</span></code>condition_variable一般更优化<br id="es6n"><br id="w0tf"><font id="uen9" size="4"><a id="gqyb" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.once"><b id="aha7"> One-time Initialization</b></a></font><br id="zdnp">仅运行一次的例程<br id="dwpr">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<br id="o3bn">[注：还未使用过]<br id="ekg5"><br id="s-p1"><font id="h8wr" size="4"><a id="jb_7" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/synchronization.html#thread.synchronization.barriers"><b id="c7im"> Barriers</b></a></font><br id="m95_">[注：还未使用过]<br id="wqh:"><br id="ap1i"><br id="dore0"></div><br id="ohnr"><img src ="http://www.cppblog.com/frank28/aggbug/48431.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/frank28/" target="_blank">frank28_nfls</a> 2008-04-29 14:28 <a href="http://www.cppblog.com/frank28/archive/2008/04/29/48431.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[boost.thread] Thread Local Storage</title><link>http://www.cppblog.com/frank28/archive/2008/04/29/48430.html</link><dc:creator>frank28_nfls</dc:creator><author>frank28_nfls</author><pubDate>Tue, 29 Apr 2008 06:26:00 GMT</pubDate><guid>http://www.cppblog.com/frank28/archive/2008/04/29/48430.html</guid><wfw:comment>http://www.cppblog.com/frank28/comments/48430.html</wfw:comment><comments>http://www.cppblog.com/frank28/archive/2008/04/29/48430.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/frank28/comments/commentRss/48430.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/frank28/services/trackbacks/48430.html</trackback:ping><description><![CDATA[                        <a id="oij2" href="http://www.stlchina.org/twiki/bin/view.pl/Main/BoostThread#4%20%E7%BA%BF%E7%A8%8B%E5%B1%80%E9%83%A8%E5%AD%98%E5%82%A8">线程局部存储（中文说明）</a> (<a title="Another one" href="http://www.cppblog.com/tx7do/archive/2008/04/29/48425.html" id="l0ni">Another one</a> )<br id="noxa"><br id="agzm">典型的应用场景是errno。<br id="srgy"><br id="jnv7">     Boost线程库提供了智能指针boost::thread_specific_ptr来访问本地存储线程。是跨平台的解决方案<br id="pmu4"><a title="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_local_storage.html" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_local_storage.html" id="a5.d">http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_local_storage.html</a> <br id="k25j"><br id="lfii"><h4 id="t9mq"><a id="zqbo" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_local_storage.html#thread.thread_local_storage.cleanup_at_thread_exit">Portable       thread-local storage with boost::thread_specific_ptr</a></h4><br id="go60"><h4 id="ly_c"><a id="xy13" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_local_storage.html#thread.thread_local_storage.cleanup_at_thread_exit">Cleanup       at thread exit</a></h4><br id="a-vk">[注：还没有实践过，等写过相应代码后再来补充文档]<br id="wm01"><br id="anyt"><br id="g1b20"><br id="pp.90"><img src ="http://www.cppblog.com/frank28/aggbug/48430.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/frank28/" target="_blank">frank28_nfls</a> 2008-04-29 14:26 <a href="http://www.cppblog.com/frank28/archive/2008/04/29/48430.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[boost.thread]Thread Management</title><link>http://www.cppblog.com/frank28/archive/2008/04/29/48429.html</link><dc:creator>frank28_nfls</dc:creator><author>frank28_nfls</author><pubDate>Tue, 29 Apr 2008 06:25:00 GMT</pubDate><guid>http://www.cppblog.com/frank28/archive/2008/04/29/48429.html</guid><wfw:comment>http://www.cppblog.com/frank28/comments/48429.html</wfw:comment><comments>http://www.cppblog.com/frank28/archive/2008/04/29/48429.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/frank28/comments/commentRss/48429.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/frank28/services/trackbacks/48429.html</trackback:ping><description><![CDATA[            <a title="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html" id="b9l5">http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html</a> <br id="dhfg"><br id="d-1i"><font id="w7xo" size="4"><b id="e9g30">launching threads</b></font><br id="bk7-"> boost::thread类代表一个可执行的线程(thread of execution)。<br id="o-fc">A new thread is launched by <span id="qtdb"><b id="e9g31">passing an object of a callable type</b></span> that <span id="frki"><b id="e9g32">can be       invoked with no parameters to the constructor</b></span>. <br id="bbxx"> The object is then copied into       internal storage, and invoked on the newly-created thread of execution.<br id="gmzr">        If you wish to construct an instance of <a id="j:-o" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#thread.thread_management.thread" title="Class thread">boost::thread</a>       <span id="r6d:"><b id="e9g33">with a function or callable object</b></span> that <span id="jobe"><b id="e9g34">requires arguments</b></span> to be supplied,       this can be done using <span id="fw.2"><b id="e9g35">boost::bind.<br id="lvi3"> </b></span>（thread non-copiable, but movable; object that used to created a thread must callable, if not, use boost::ref）<span id="fw.2"><br id="ocdh"><b id="e9g36"> <br id="mwbl"> </b></span><font id="foj6" size="4"><span id="fw.2"><b id="e9g37">Joining and detaching</b></span></font><span id="fw.2"><br id="lsbl"> </span>当代表一个可执行的线程(<span id="xqf-"><b id="e9g38"><i id="e9g39">thread of execution</i></b></span>)的boost::thread对象被销毁时，这个线程便同时被<span id="ihma"><b id="e9g310">detached</b></span>. Detached的线程将继续运行直到线程终止。<br id="w9kr"> 也可以显式调用(explicitly)一个boost::thread对象的detach()方法，这时这个线程直接被detach，而这个boost::thread对象讲不再代表thread of execution，而指<span id="mocb" class="emphasis"><i id="txuk"><span id="kcdt"><b id="e9g311">Not-a-Thread</b></span><br id="juwg"> <br id="zmms"> </i></span><span id="quqa"><b id="e9g312">join()</b></span>用于等待一个线程结束。<br id="ea24">(timed_join())<span id="mocb" class="emphasis"><i id="txuk"><br id="smz-"> <br id="mrbp"> </i></span><font id="mzk9" size="4"><span id="jf9z"><b id="e9g313">Interruption</b></span></font><br id="epp-"> 调用boost::thread对象的<span id="fvio"><b id="e9g314">interrupt()</b></span>方法，可以中断其对应的线程。<br id="aa5i"> When the interrupted thread next executes one of the specified <a id="uc2v" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#interruption_points">interruption points</a>       (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.<br id="y2c1"> (boost::this_thread::disable_interruption, <font id="c6qb" size="2"><a id="ev8s" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#thread.thread_management.predefined_interruption_points"><span id="hbrv"><b id="e9g315">Predefined       Interruption Points</b></span></a></font><font id="t8is" size="2">)<br id="ofze"><br id="z1_q"><font id="k0xq" size="4"><span id="ko0l"><b id="e9g316">Thread IDs</b></span></font><br id="x2yq">每一个运行中的thread都有一个唯一的id值。<br id="neiu"></font>调用对应的<a id="b9db" class="link" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#thread.thread_management.thread" title="Class thread"></a><code id="pl0m">boost::thread对象的</code><code id="ndx1" class="computeroutput"><span id="p7t8" class="identifier">get_id</span><span id="lxa4" class="special">()方法</span></code>，或者在运行的thread中调用<code id="tu3j" class="computeroutput"><span id="x8s2" class="identifier">boost</span><span id="bv7b" class="special">::</span><span id="oz1a" class="identifier">this_thread</span><span id="gt80" class="special">::</span><span id="mmxo" class="identifier">get_id</span><span id="jeja" class="special">()</span></code>方法。<br id="h8n3"><font id="rebf" size="4"><br style="font-weight: bold;" id="iihq"><span id="x8xf"><b id="e9g317">Namespace this_thread</b></span></font><br id="xjb4"> this_thread下包含的是在正在运行的线程内部，所能进行的线程操作，包括上面提到的get_id()方法<br id="ezjd"><a title="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#thread.thread_management.this_thread" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#thread.thread_management.this_thread" id="y-0c">http://www.boost.org/doc/libs/1_35_0/doc/html/thread/thread_management.html#thread.thread_management.this_thread</a> <br id="fzvw">             <br id="tk_t"><font id="h6iw" size="4"><span id="wlqp"><b id="e9g318">Thread Group</b></span></font><br id="t6nx"><span id="y4up"><b id="e9g319">thread_group</b></span> class provides for         a collection of threads that are related in some fashion. <br id="v25_">New threads can         be added to the group with <span id="b8.1"><b id="e9g320">add_thread</b></span>         and <span id="f8hs"><b id="e9g321">create_thread</b></span> member         functions. <br id="ddak">thread_group is         <span id="he.b"><b id="e9g322">not copyable or movable</b></span>.<br id="f.p4"><br id="n9lu"><br id="xng00"><img src ="http://www.cppblog.com/frank28/aggbug/48429.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/frank28/" target="_blank">frank28_nfls</a> 2008-04-29 14:25 <a href="http://www.cppblog.com/frank28/archive/2008/04/29/48429.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[Boost] Thread 笔记</title><link>http://www.cppblog.com/frank28/archive/2008/04/29/boost_thread.html</link><dc:creator>frank28_nfls</dc:creator><author>frank28_nfls</author><pubDate>Tue, 29 Apr 2008 06:12:00 GMT</pubDate><guid>http://www.cppblog.com/frank28/archive/2008/04/29/boost_thread.html</guid><wfw:comment>http://www.cppblog.com/frank28/comments/48424.html</wfw:comment><comments>http://www.cppblog.com/frank28/archive/2008/04/29/boost_thread.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/frank28/comments/commentRss/48424.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/frank28/services/trackbacks/48424.html</trackback:ping><description><![CDATA[基础概念：<br id="hire"><br id="l.de">
<div id="dz3j" style="margin-left: 40px;">原文：<a id="p-of" title="http://www-eleves-isia.cma.fr/documentation/BoostDoc/boost_1_29_0/libs/thread/doc/definitions.html" href="http://www-eleves-isia.cma.fr/documentation/BoostDoc/boost_1_29_0/libs/thread/doc/definitions.html">http://www-eleves-isia.cma.fr/documentation/BoostDoc/boost_1_29_0/libs/thread/doc/definitions.html</a><br id="ize.">
<div id="m0og0">backup<span id="m0og1">：http://docs.google.com/Doc?id=dgnd783p_138c62cd2gb</span><br id="uz0n"></div>
这是1.29.0版boost文档中的定义，参考了C++ standard，并结合boost作了解释，很规范，介绍了以下基本概念：<br id="n3p1">Thread、Thread-safe、Thread State、Race Condition、Deadlock、Starvation、Priority Failure、Memory Visibility<br id="ddpp">新版boost文档中已经没有这一章了<br id="f8.2"></div>
<br id="xjhu">
<div id="z3gi" style="margin-left: 40px;">boost.thread官方文档1.35.0<br id="yf7l"><a id="eiqj" title="http://www.boost.org/doc/libs/1_35_0/doc/html/thread.html" href="http://www.boost.org/doc/libs/1_35_0/doc/html/thread.html">http://www.boost.org/doc/libs/1_35_0/doc/html/thread.html</a><br id="m_xo"></div>
<br id="q5g1">
<ul id="sx3b" style="margin-left: 40px;">
    <li id="cyzs"><a target="" accesskey="" tabindex="0" class="" id="i-8g" title="Thread management" href="http://www.cppblog.com/frank28/archive/2008/04/29/48429.html">Thread Management</a><br id="zjm60">http://docs.google.com/Doc?id=dgnd783p_142fgzzpbcv<br id="zjm61">
    </li>
    <li id="vb86"><a id="mmni" title="Synchronization" href="http://www.cppblog.com/frank28/archive/2008/04/29/48431.html">Synchronization<br id="zjm62"></a>http://docs.google.com/Doc?id=dgnd783p_146crx42gn9<br id="f_mi0">
    </li>
    <li id="qjmk"><a id="m07f" title="Thread local storage" href="http://www.cppblog.com/frank28/archive/2008/04/29/48430.html">Thread Local Storage</a><br id="f_mi1">http://docs.google.com/Doc?id=dgnd783p_147hjchrgf8 </li>
</ul>
<br id="v0st">参考：<br id="lzd6"><br id="s4do">
<ol id="xhpw">
    <li id="zos0"><a id="r-lm" title="http://www.cs.cf.ac.uk/Dave/C/node32.html" href="http://www.cs.cf.ac.uk/Dave/C/node32.html">http://www.cs.cf.ac.uk/Dave/C/node32.html</a><br id="l4tz">一个c/pthread的thread教程，有一些典型例子的代码、算法说明
    </li>
    <li id="hddo"><a id="vz9e" title="http://www.stlchina.org/twiki/bin/view.pl/Main/BoostThread#C++%20Boost%20Thread%20%B1%E0%B3%CC%D6%B8%C4%CF" href="http://www.stlchina.org/twiki/bin/view.pl/Main/BoostThread#C++%20Boost%20Thread%20%B1%E0%B3%CC%D6%B8%C4%CF">http://www.stlchina.org/twiki/bin/view.pl/Main/BoostThread#C++%20Boost%20Thread%20%B1%E0%B3%CC%D6%B8%C4%CF</a><br id="p-m4">C++ Boost Thread 编程指南（中文版）<br id="uhdt"><a id="ut6o" title="http://www.ddj.com/cpp/184401518" href="http://www.ddj.com/cpp/184401518">http://www.ddj.com/cpp/184401518</a><br id="kv.q">英文原版<br id="u-0d">WARNING：Out-of-Date（2002年的）! 只能参考用<br id="ml48">
    </li>
    <li id="hddo"><a id="qgwe" title="http://aszt.inf.elte.hu/~gsd/klagenfurt/material/ch03s06.html" href="http://aszt.inf.elte.hu/%7Egsd/klagenfurt/material/ch03s06.html">http://aszt.inf.elte.hu/~gsd/klagenfurt/material/ch03s06.html</a><br id="oq1-">英文的一篇boost.thread说明，里面有boost::thread的简单例子，其中一个使用了condition<br id="xi23">WARNING：Out-of-Date! 只能参考用 </li>
</ol>
<br id="m3jo">Code：<br id="l44p"><br id="hvqf">
<ul id="jgad">
    <li id="al1y"><a  href="http://docs.google.com/Doc?id=dgnd783p_143g85628n7">producer/consumer</a><br id="b9nl0"><br></li>
</ul>
<br id="b9nl1"><br id="j1yh"><br id="lyyn"><br id="bjy7">   <img src ="http://www.cppblog.com/frank28/aggbug/48424.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/frank28/" target="_blank">frank28_nfls</a> 2008-04-29 14:12 <a href="http://www.cppblog.com/frank28/archive/2008/04/29/boost_thread.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>试试看博客园的blog~</title><link>http://www.cppblog.com/frank28/archive/2008/04/24/48018.html</link><dc:creator>frank28_nfls</dc:creator><author>frank28_nfls</author><pubDate>Thu, 24 Apr 2008 07:55:00 GMT</pubDate><guid>http://www.cppblog.com/frank28/archive/2008/04/24/48018.html</guid><wfw:comment>http://www.cppblog.com/frank28/comments/48018.html</wfw:comment><comments>http://www.cppblog.com/frank28/archive/2008/04/24/48018.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/frank28/comments/commentRss/48018.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/frank28/services/trackbacks/48018.html</trackback:ping><description><![CDATA[原本是想<a  href="http://blog.csdn.net/frank28_nfls/archive/2008/04/17/2300300.aspx">把新blog架在csdn上</a>的<br><br><br>然而csdn不让全文输出rss这一点就足足把我逼走<br><br>现在开始试试看这里，感觉这里能满足我大部分要求，但愿这次就能彻底定下来了。。。<br><br> <img src ="http://www.cppblog.com/frank28/aggbug/48018.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/frank28/" target="_blank">frank28_nfls</a> 2008-04-24 15:55 <a href="http://www.cppblog.com/frank28/archive/2008/04/24/48018.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>