/usr/share/doc/ucommon-doc/html/a00774.html is in ucommon-doc 7.0.0-9.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>UCommon: thread.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">UCommon
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',false,false,'search.php','Search');
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">thread.cpp</div> </div>
</div><!--header-->
<div class="contents">
<p>A simple example of threading and join operation.</p>
<div class="fragment"><div class="line"><span class="comment">// Copyright (C) 2006-2014 David Sugar, Tycho Softworks.</span></div><div class="line"><span class="comment">// Copyright (C) 2015 Cherokees of Idaho.</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// This file is part of GNU uCommon C++.</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span></div><div class="line"><span class="comment">// it under the terms of the GNU Lesser General Public License as published</span></div><div class="line"><span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span></div><div class="line"><span class="comment">// (at your option) any later version.</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span></div><div class="line"><span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div><div class="line"><span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span></div><div class="line"><span class="comment">// GNU Lesser General Public License for more details.</span></div><div class="line"><span class="comment">//</span></div><div class="line"><span class="comment">// You should have received a copy of the GNU Lesser General Public License</span></div><div class="line"><span class="comment">// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.</span></div><div class="line"></div><div class="line"><span class="preprocessor">#ifndef DEBUG</span></div><div class="line"><span class="preprocessor">#define DEBUG</span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include <<a class="code" href="a00503.html">ucommon/ucommon.h</a>></span></div><div class="line"></div><div class="line"><span class="preprocessor">#include <stdio.h></span></div><div class="line"></div><div class="line"><span class="keyword">using namespace </span><a class="code" href="a00563.html">ucommon</a>;</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">unsigned</span> count = 0;</div><div class="line"></div><div class="line"><span class="keyword">class </span>testLocal : <span class="keyword">public</span> Thread::Local</div><div class="line">{</div><div class="line"><span class="keyword">private</span>:</div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> release(<span class="keywordtype">void</span> *mem) __FINAL {</div><div class="line"> ::free(mem);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keyword">virtual</span> <span class="keywordtype">void</span> *allocate() __FINAL {</div><div class="line"> return ::malloc(100);</div><div class="line"> }</div><div class="line">};</div><div class="line"></div><div class="line"><span class="keyword">static</span> testLocal local;</div><div class="line"></div><div class="line"><span class="keyword">class </span>testThread : <span class="keyword">public</span> JoinableThread</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"> testThread() : JoinableThread() {};</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> run(<span class="keywordtype">void</span>) {</div><div class="line"> assert(local.get() == <span class="keyword">nullptr</span>);</div><div class="line"> assert(*local != <span class="keyword">nullptr</span>);</div><div class="line"></div><div class="line"> ++count;</div><div class="line"> ::sleep(2);</div><div class="line"> };</div><div class="line">};</div><div class="line"></div><div class="line"><span class="keyword">extern</span> <span class="stringliteral">"C"</span> <span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line"> time_t now, later;</div><div class="line"> testThread *thr;</div><div class="line"> <span class="keywordtype">void</span> *mem;</div><div class="line"></div><div class="line"> assert(local.get() == <span class="keyword">nullptr</span>);</div><div class="line"> mem = *local;</div><div class="line"> assert(mem != <span class="keyword">nullptr</span>);</div><div class="line"> assert(mem == *local);</div><div class="line"></div><div class="line"> time(&now);</div><div class="line"> thr = <span class="keyword">new</span> testThread();</div><div class="line"> thr->start();</div><div class="line"> Thread::sleep(10);</div><div class="line"> <span class="keyword">delete</span> thr;</div><div class="line"> assert(count == 1);</div><div class="line"> time(&later);</div><div class="line"> assert(later >= now + 1);</div><div class="line"></div><div class="line"> time(&now);</div><div class="line"> TimedEvent evt;</div><div class="line"> evt.wait(2000);</div><div class="line"> time(&later);</div><div class="line"> assert(later >= now + 1);</div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line">}</div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.12
</small></address>
</body>
</html>
|