亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mutex_8h-source.html

?? 用來介紹ZIG Library游戲網絡引擎的文檔
?? HTML
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>mutex.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center><hr><h1>mutex.h</h1><div class="fragment"><pre>00001 <span class="comment">/*</span>00002 <span class="comment">    ZIG - An extendable, portable game engine focused on networking &amp; scripting</span>00003 <span class="comment">    Project Home: http://zige.sourceforge.net</span>00004 <span class="comment">    Copyright (C) 2002  F醔io Reis Cecin &lt;fcecin AT inf DOT ufrgs DOT br&gt;</span>00005 <span class="comment"></span>00006 <span class="comment">    This library is free software; you can redistribute it and/or</span>00007 <span class="comment">    modify it under the terms of the GNU Lesser General Public</span>00008 <span class="comment">    License as published by the Free Software Foundation; either</span>00009 <span class="comment">    version 2.1 of the License, or (at your option) any later version.</span>00010 <span class="comment"></span>00011 <span class="comment">    This library is distributed in the hope that it will be useful,</span>00012 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>00013 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>00014 <span class="comment">    Lesser General Public License for more details.</span>00015 <span class="comment"></span>00016 <span class="comment">    You should have received a copy of the GNU Lesser General Public</span>00017 <span class="comment">    License along with this library; if not, write to the Free Software</span>00018 <span class="comment">    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   </span>00019 <span class="comment">*/</span>00020 <span class="comment">/*</span>00021 <span class="comment"></span>00022 <span class="comment">        mutex for threading</span>00023 <span class="comment"></span>00024 <span class="comment">        as of ZIG v1.4.0, this is not needed anymore (moved back to thread.h)</span>00025 <span class="comment"></span>00026 <span class="comment">*/</span>00027 <span class="comment">/*</span>00028 <span class="comment">#ifndef _ZIG_HEADER_MUTEX_H_</span>00029 <span class="comment">#define _ZIG_HEADER_MUTEX_H_</span>00030 <span class="comment"></span>00031 <span class="comment">#ifndef NO_DOXYGEN              // internal class -- do not document</span>00032 <span class="comment"></span>00033 <span class="comment">// ================================================</span>00034 <span class="comment">// our does-the-job-without-getting-in-your-way</span>00035 <span class="comment">// set of classes that wrap up the pthreads API</span>00036 <span class="comment">// ================================================</span>00037 <span class="comment"></span>00038 <span class="comment">// ZIG 1.4.0: this should stay #define'd -- switches the mutex code to use hawkthreads.h</span>00039 <span class="comment">// instead of pthread.h</span>00040 <span class="comment">//#define USE_HAWKTHREADS</span>00041 <span class="comment"></span>00042 <span class="comment">#ifdef USE_HAWKTHREADS</span>00043 <span class="comment">#include &lt;hawkthreads.h&gt;</span>00044 <span class="comment">#else</span>00045 <span class="comment">#include &lt;pthread.h&gt;</span>00046 <span class="comment">#endif</span>00047 <span class="comment"></span>00048 <span class="comment">#include "utils.h"</span>00049 <span class="comment"></span>00050 <span class="comment">class console_c;</span>00051 <span class="comment"></span>00056 <span class="comment">#ifdef USE_HAWKTHREADS</span>00057 <span class="comment">#define THREAD_INVALID (HThreadID)HT_INVALID</span>00058 <span class="comment">#else</span>00059 <span class="comment">#define THREAD_INVALID (pthread_t)-1</span>00060 <span class="comment">#endif</span>00061 <span class="comment"></span>00062 <span class="comment"></span>00067 <span class="comment">class mutex_c {</span>00068 <span class="comment">public:</span>00069 <span class="comment"></span>00071 <span class="comment">        mutex_c() {</span>00072 <span class="comment">                //con = 0;</span>00073 <span class="comment">                numlock = 0;</span>00074 <span class="comment">                owner = THREAD_INVALID;</span>00075 <span class="comment">                int r;</span>00076 <span class="comment">#ifdef USE_HAWKTHREADS</span>00077 <span class="comment">                r = htMutexInit(&amp;m);</span>00078 <span class="comment">                assert(r == 0);</span>00079 <span class="comment">                r = htMutexInit(&amp;c);</span>00080 <span class="comment">                assert(r == 0);</span>00081 <span class="comment">#else</span>00082 <span class="comment">                r = pthread_mutex_init(&amp;m, 0);</span>00083 <span class="comment">                assert(r == 0);</span>00084 <span class="comment">                r = pthread_mutex_init(&amp;c, 0);</span>00085 <span class="comment">                assert(r == 0);</span>00086 <span class="comment">#endif</span>00087 <span class="comment">        }</span>00088 <span class="comment"></span>00090 <span class="comment">        //void set_console(console_c *conio) { con = conio; }</span>00091 <span class="comment"></span>00095 <span class="comment">        bool lock() {</span>00096 <span class="comment">                pthread_t id = pthread_self();</span>00097 <span class="comment">                 count_lock();</span>00098 <span class="comment">                if (owner != id) { // different thread. go ahead and try to lock it</span>00099 <span class="comment">                         count_unlock();</span>00100 <span class="comment">                        //if (con) con-&gt;dprintf("MUTEX %i locking... owner %i\n", m, owner);</span>00101 <span class="comment">                        int r = pthread_mutex_lock(&amp;m);</span>00102 <span class="comment">                        if (r != 0) { </span>00103 <span class="comment">//                              if (con) </span>00104 <span class="comment">//                                      con-&gt;xprintf(5, "ERROR MUTEX %i LOCK == %i\n", m, r);</span>00105 <span class="comment">                                FAILSTOP();  // trap "can't lock" errors</span>00106 <span class="comment">                        }</span>00107 <span class="comment">                        //if (con) con-&gt;dprintf("MUTEX %i locked (%i)\n", m, r);</span>00108 <span class="comment">                         count_lock(); // inside critical section - so set owner and numlock to 1</span>00109 <span class="comment">                        owner = id;</span>00110 <span class="comment">                        numlock = 1;</span>00111 <span class="comment">                         count_unlock();</span>00112 <span class="comment">                        return (r == 0);</span>00113 <span class="comment">                }</span>00114 <span class="comment">                else {</span>00115 <span class="comment">                        numlock++;        // thread that already owns the lock. just increment the counter</span>00116 <span class="comment">                        if (numlock &gt; 16)  </span>00117 <span class="comment">                                FAILSTOP();  // FAIL - too many recursive locks, may be in a loop...</span>00118 <span class="comment">                         count_unlock();</span>00119 <span class="comment">                        return true;</span>00120 <span class="comment">                }</span>00121 <span class="comment">        }</span>00122 <span class="comment"></span>00124 <span class="comment">        bool unlock() {</span>00125 <span class="comment">                pthread_t id = pthread_self();</span>00126 <span class="comment">                 count_lock();</span>00127 <span class="comment">                if (owner != id) {</span>00128 <span class="comment">                         count_unlock();</span>00129 <span class="comment">                        FAILSTOP();    // FAIL - let's trap this</span>00130 <span class="comment">                        return false;                           //it's not the thread that owns the lock! error!</span>00131 <span class="comment">                }</span>00132 <span class="comment">                else {</span>00133 <span class="comment">                        if (numlock &lt;= 0) {</span>00134 <span class="comment">                                FAILSTOP(); // FAIL - unlocking more than locking!</span>00135 <span class="comment">                        }</span>00136 <span class="comment">                        numlock--;      // decrement lock count</span>00137 <span class="comment">                        if (numlock == 0) {  // no more lock counts - remove entry, do unlock</span>00138 <span class="comment">                                owner = THREAD_INVALID; // set owner to "nobody"</span>00139 <span class="comment">                                 count_unlock();</span>00140 <span class="comment">                                //if (con) con-&gt;dprintf("MUTEX %i unlocking... owner %i\n", m, owner);</span>00141 <span class="comment">                                int r = pthread_mutex_unlock(&amp;m);</span>00142 <span class="comment">                                if (r != 0) {</span>00143 <span class="comment">                                        FAILSTOP();  // trap "can't unlock" errors</span>00144 <span class="comment">//                                      if (con) </span>00145 <span class="comment">//                                              con-&gt;xprintf(5, "ERROR: MUTEX %i UNLOCK == %i\n", m, r);</span>00146 <span class="comment">                                }</span>00147 <span class="comment">                                //if (con) con-&gt;dprintf("MUTEX %i unlocked (%i)\n", m, r);</span>00148 <span class="comment">                                return (r == 0);</span>00149 <span class="comment">                        }</span>00150 <span class="comment">                        else {</span>00151 <span class="comment">                                count_unlock(); // do nothing, still more unlocks to go.</span>00152 <span class="comment">                                return true;</span>00153 <span class="comment">                        }</span>00154 <span class="comment">                }</span>00155 <span class="comment">        }</span>00156 <span class="comment"></span>00158 <span class="comment">        virtual ~mutex_c() {</span>00159 <span class="comment">                int r;</span>00160 <span class="comment">#ifdef USE_HAWKTHREADS</span>00161 <span class="comment">                r = htMutexDestroy(&amp;m);</span>00162 <span class="comment">                r = htMutexDestroy(&amp;c);</span>00163 <span class="comment">#else</span>00164 <span class="comment">                r = pthread_mutex_destroy(&amp;m);</span>00165 <span class="comment">                assert(r == 0);</span>00166 <span class="comment">                r = pthread_mutex_destroy(&amp;c);</span>00167 <span class="comment">                assert(r == 0);</span>00168 <span class="comment">#endif</span>00169 <span class="comment">        }</span>00170 <span class="comment"></span>00171 <span class="comment">protected:</span>00172 <span class="comment"></span>00173 <span class="comment">        void count_lock() { int r = pthread_mutex_lock(&amp;c); if (r != 0) FAILSTOP();     }</span>00174 <span class="comment">        void count_unlock() { int r = pthread_mutex_unlock(&amp;c); if (r != 0) FAILSTOP(); }</span>00175 <span class="comment">        pthread_t owner;        // thread that owns the mutex and is inside the critical section</span>00176 <span class="comment">        int numlock; // number of times the owner thread has locked</span>00177 <span class="comment">        console_c *con; //debugging...</span>00178 <span class="comment"></span>00179 <span class="comment">private:</span>00180 <span class="comment"></span>00181 <span class="comment">#ifdef USE_HAWKTHREADS</span>00182 <span class="comment">        HTmutex m;</span>00183 <span class="comment">        HTmutex c;</span>00184 <span class="comment">#else</span>00185 <span class="comment">        pthread_mutex_t m; //the mutex</span>00186 <span class="comment">        pthread_mutex_t c; //mutex for accessing the lock counter map</span>00187 <span class="comment">#endif</span>00188 <span class="comment"></span>00189 <span class="comment">        //non-copyable</span>00190 <span class="comment">        mutex_c(const mutex_c&amp;){}</span>00191 <span class="comment">        mutex_c &amp;operator=(const mutex_c&amp;);</span>00192 <span class="comment">};</span>00193 <span class="comment"></span>00194 <span class="comment"></span>00195 <span class="comment">#endif // NO_DOXYGEN</span>00196 <span class="comment"></span>00197 <span class="comment">#endif // _MUTEX_H_</span>00198 <span class="comment"></span>00199 <span class="comment"></span>00200 <span class="comment">*/</span></pre></div><hr><address style="align: right;"><small>Generated on Mon Jan 24 21:14:23 2005 for ZIG by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美午夜精品一区二区蜜桃| 色综合中文综合网| 欧美va亚洲va在线观看蝴蝶网| 韩国一区二区视频| 亚洲一二三级电影| 国产精品久久久一区麻豆最新章节| 最新国产の精品合集bt伙计| 日韩女优av电影| 日韩一级免费观看| 欧美影院午夜播放| 欧美精品一区二区三区在线| 日韩欧美国产一区在线观看| 亚洲品质自拍视频| 亚洲另类色综合网站| 一区在线观看视频| 亚洲精品国产一区二区精华液 | 色视频成人在线观看免| 99在线视频精品| 成人免费福利片| 91美女视频网站| 在线观看免费一区| 91精品国产aⅴ一区二区| 日韩一二三四区| 亚洲午夜成aⅴ人片| 欧美专区日韩专区| 亚洲免费观看高清在线观看| www.在线成人| 国产精品毛片高清在线完整版| 亚洲视频一二三区| av一二三不卡影片| 国产精品麻豆视频| 99久久免费精品高清特色大片| 制服丝袜日韩国产| 久久综合成人精品亚洲另类欧美| 国产午夜一区二区三区| 国产精品久久三| 成人小视频免费观看| 国产嫩草影院久久久久| 亚洲福利电影网| 欧美日韩国产a| 国产精品免费免费| 成人18精品视频| 日韩欧美电影在线| 久久99国产精品免费| 91丨九色丨蝌蚪丨老版| 亚洲欧美福利一区二区| 欧美性受xxxx黑人xyx性爽| 五月婷婷久久丁香| 成人白浆超碰人人人人| 亚洲精品日韩专区silk| 欧美性受xxxx| 蜜桃久久久久久久| 色偷偷88欧美精品久久久| 亚洲综合色丁香婷婷六月图片| 大陆成人av片| 亚洲欧美日韩系列| 精品视频在线看| 亚洲精品一二三四区| 欧美日韩国产综合久久| 精品一区二区三区在线视频| 国产精品免费aⅴ片在线观看| 欧洲生活片亚洲生活在线观看| 日韩国产精品久久久| 91麻豆.com| 日本成人在线电影网| 中文一区二区在线观看| 国产精品主播直播| 亚洲精品一区二区三区福利| 99视频精品全部免费在线| 三级成人在线视频| 欧美日韩一区二区三区不卡 | 亚洲靠逼com| 欧美成人女星排名| av电影天堂一区二区在线| 日韩成人一级片| 亚洲色图视频网站| 亚洲精品在线三区| 欧美日韩国产综合一区二区三区| 国产丶欧美丶日本不卡视频| 久久视频一区二区| 欧美亚洲国产一区二区三区va| 久久99久久99小草精品免视看| 亚洲激情图片小说视频| 国产人成亚洲第一网站在线播放 | 欧美亚洲一区二区三区四区| 国产在线精品一区在线观看麻豆| 亚洲午夜视频在线观看| 国产亚洲人成网站| 精品日韩欧美一区二区| 欧美日韩激情在线| 97久久精品人人做人人爽50路| 精品一区二区影视| 免费一级片91| 国产亚洲欧美在线| 欧美精品一卡两卡| 蜜桃久久精品一区二区| 夜夜揉揉日日人人青青一国产精品 | 国产精品视频观看| www成人在线观看| 欧美一区二区三区成人| 欧洲人成人精品| 99精品视频在线免费观看| 国产一本一道久久香蕉| 国产清纯白嫩初高生在线观看91 | 欧美日韩在线播放| 色婷婷亚洲精品| av中文字幕亚洲| 不卡一二三区首页| 粗大黑人巨茎大战欧美成人| 国产精品一区专区| 精品在线播放免费| 精品一区二区三区在线观看 | 久久精品国产99国产精品| 国产日韩v精品一区二区| 7878成人国产在线观看| 欧美日韩免费电影| 欧美日本在线观看| 欧美日韩高清在线| 6080午夜不卡| 精品国内二区三区| 久久精品人人做人人爽人人| 久久久99久久精品欧美| 色久综合一二码| 精品在线播放免费| 国产乱子伦一区二区三区国色天香| 精品在线播放免费| 懂色av一区二区在线播放| 午夜视频在线观看一区| 日本欧美韩国一区三区| 精品伊人久久久久7777人| 国产米奇在线777精品观看| 成人av免费在线| 欧美私模裸体表演在线观看| 欧美日本在线观看| 日韩欧美国产综合| 中文字幕电影一区| 亚洲网友自拍偷拍| 免费成人性网站| 成人免费视频视频在线观看免费| 99久久精品99国产精品| 欧美日韩亚洲综合一区| 精品日韩一区二区三区免费视频| 欧美国产成人在线| 亚洲午夜成aⅴ人片| 久久国产日韩欧美精品| 成人免费视频网站在线观看| 欧美色图12p| 欧美精品一区二区三区一线天视频| 国产精品日韩精品欧美在线 | 日韩美女视频一区二区 | 波多野结衣中文字幕一区 | 中文字幕在线观看一区| 午夜亚洲国产au精品一区二区| 免费看欧美女人艹b| 波多野结衣精品在线| 91精品国产欧美一区二区成人| 国产精品看片你懂得| 免费欧美在线视频| 日本高清不卡一区| 精品国产乱码久久久久久1区2区 | 乱中年女人伦av一区二区| 成人aa视频在线观看| 日韩免费高清视频| 一区二区三区在线视频观看58 | 久久久久久久久伊人| 亚洲午夜羞羞片| 99国产精品久久久| 亚洲精品在线三区| 视频一区二区中文字幕| www.久久久久久久久| 欧美大片拔萝卜| 亚洲18女电影在线观看| 婷婷丁香激情综合| 色诱视频网站一区| 欧美国产精品v| 国产乱人伦精品一区二区在线观看 | 肉丝袜脚交视频一区二区| 色综合网色综合| 日本一区二区三区国色天香| 免费成人性网站| 欧美狂野另类xxxxoooo| 一区二区三区蜜桃| 91麻豆蜜桃一区二区三区| 久久久久久久综合狠狠综合| 蜜臀久久99精品久久久画质超高清 | 91一区二区在线观看| 国产欧美精品国产国产专区 | 国产精品人成在线观看免费| 精品在线亚洲视频| 精品国产制服丝袜高跟| 蜜臀av一区二区| 91精品欧美久久久久久动漫| 亚洲v中文字幕| 欧美视频一区在线| 一区二区三区在线免费| 91浏览器打开| 亚洲乱码一区二区三区在线观看| 波多野结衣亚洲一区| 亚洲视频香蕉人妖| 91在线观看地址|