/usr/share/doc/libucommon-dev/a00209_source.html is in libucommon-doc 3.2.0-0ubuntu1.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | <!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"/>
<title>UCommon: ucommon/timers.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<h1>ucommon/timers.h</h1><a href="a00209.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.</span>
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00003"></a>00003 <span class="comment">// This file is part of GNU uCommon C++.</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// GNU uCommon C++ is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU Lesser General Public License as published </span>
<a name="l00007"></a>00007 <span class="comment">// by the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// GNU uCommon C++ is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU Lesser General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU Lesser General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.</span>
<a name="l00017"></a>00017
<a name="l00027"></a>00027 <span class="preprocessor">#ifndef _UCOMMON_TIMERS_H_</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#define _UCOMMON_TIMERS_H_</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>
<a name="l00030"></a>00030 <span class="preprocessor">#ifndef _UCOMMON_LINKED_H_</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span><span class="preprocessor">#include <<a class="code" href="a00195.html" title="Linked objects, lists, templates, and containers.">ucommon/linked.h</a>></span>
<a name="l00032"></a>00032 <span class="preprocessor">#endif</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00034"></a>00034 <span class="preprocessor">#ifndef _MSWINDOWS_</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#include <unistd.h></span>
<a name="l00036"></a>00036 <span class="preprocessor">#include <sys/time.h></span>
<a name="l00037"></a>00037 <span class="preprocessor">#endif</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00039"></a>00039 <span class="preprocessor">#include <time.h></span>
<a name="l00040"></a>00040
<a name="l00041"></a>00041 NAMESPACE_UCOMMON
<a name="l00042"></a>00042
<a name="l00049"></a><a class="code" href="a00169.html">00049</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>
<a name="l00050"></a>00050 {
<a name="l00051"></a>00051 <span class="keyword">private</span>:
<a name="l00052"></a>00052 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00040.html" title="The conditional is a common base for other thread synchronizing classes.">Conditional</a>;
<a name="l00053"></a>00053 <span class="keyword">friend</span> <span class="keyword">class </span>Semaphore;
<a name="l00054"></a>00054 <span class="keyword">friend</span> <span class="keyword">class </span>Event;
<a name="l00055"></a>00055
<a name="l00056"></a>00056 <span class="preprocessor">#if _POSIX_TIMERS > 0</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span> timespec timer;
<a name="l00058"></a>00058 <span class="preprocessor">#else</span>
<a name="l00059"></a>00059 <span class="preprocessor"></span> timeval timer;
<a name="l00060"></a>00060 <span class="preprocessor">#endif</span>
<a name="l00061"></a>00061 <span class="preprocessor"></span> <span class="keywordtype">bool</span> updated;
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="keyword">public</span>:
<a name="l00064"></a><a class="code" href="a00169.html#aa3783e1d579d343cf8e55f0f907d67b8">00064</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> inf;
<a name="l00065"></a><a class="code" href="a00169.html#a7f7566f8349b5ae271d35553f0d48ac1">00065</a> <span class="keyword">static</span> <span class="keyword">const</span> time_t reset;
<a name="l00070"></a>00070 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>();
<a name="l00071"></a>00071
<a name="l00076"></a>00076 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>(<a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> offset);
<a name="l00077"></a>00077
<a name="l00082"></a>00082 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>(time_t offset);
<a name="l00083"></a>00083
<a name="l00088"></a>00088 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>(<span class="keyword">const</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& <a class="code" href="a00214.html#a8370bd49e635d1f1c3aec9135f497cec" title="Convenence function to access object copy.">copy</a>);
<a name="l00089"></a>00089
<a name="l00094"></a>00094 <span class="keywordtype">bool</span> isExpired(<span class="keywordtype">void</span>);
<a name="l00095"></a>00095
<a name="l00100"></a>00100 <span class="keywordtype">bool</span> isUpdated(<span class="keywordtype">void</span>);
<a name="l00101"></a>00101
<a name="l00106"></a>00106 <span class="keywordtype">void</span> <span class="keyword">set</span>(<a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> expire);
<a name="l00107"></a>00107
<a name="l00112"></a>00112 <span class="keywordtype">void</span> <span class="keyword">set</span>(time_t expire);
<a name="l00113"></a>00113
<a name="l00117"></a>00117 <span class="keywordtype">void</span> <span class="keyword">set</span>(void);
<a name="l00118"></a>00118
<a name="l00122"></a>00122 <span class="keywordtype">void</span> clear(<span class="keywordtype">void</span>);
<a name="l00123"></a>00123
<a name="l00128"></a>00128 <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> <span class="keyword">get</span>(void) <span class="keyword">const</span>;
<a name="l00129"></a>00129
<a name="l00134"></a><a class="code" href="a00169.html#a1dbe1af70e24331e747c5688bf0f9bfb">00134</a> <span class="keyword">inline</span> <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> operator*()<span class="keyword"> const</span>
<a name="l00135"></a>00135 <span class="keyword"> </span>{<span class="keywordflow">return</span> <span class="keyword">get</span>();};
<a name="l00136"></a>00136
<a name="l00141"></a>00141 <span class="keywordtype">bool</span> operator!() <span class="keyword">const</span>;
<a name="l00142"></a>00142
<a name="l00147"></a>00147 operator bool() <span class="keyword">const</span>;
<a name="l00148"></a>00148
<a name="l00153"></a>00153 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& operator=(time_t expire);
<a name="l00154"></a>00154
<a name="l00159"></a>00159 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& operator=(<a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> expire);
<a name="l00160"></a>00160
<a name="l00165"></a>00165 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& operator+=(time_t expire);
<a name="l00166"></a>00166
<a name="l00171"></a>00171 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& operator+=(<a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> expire);
<a name="l00172"></a>00172
<a name="l00177"></a>00177 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& operator-=(time_t expire);
<a name="l00178"></a>00178
<a name="l00183"></a>00183 <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& operator-=(<a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> expire);
<a name="l00184"></a>00184
<a name="l00190"></a>00190 <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> operator-(<span class="keyword">const</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& timer);
<a name="l00191"></a>00191
<a name="l00197"></a>00197 <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& timer);
<a name="l00198"></a>00198
<a name="l00204"></a>00204 <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& timer);
<a name="l00205"></a>00205
<a name="l00211"></a>00211 <span class="keywordtype">bool</span> operator<(<span class="keyword">const</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& timer);
<a name="l00212"></a>00212
<a name="l00218"></a>00218 <span class="keywordtype">bool</span> operator<=(<span class="keyword">const</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& timer);
<a name="l00219"></a>00219
<a name="l00225"></a>00225 <span class="keywordtype">bool</span> operator>(<span class="keyword">const</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& timer);
<a name="l00226"></a>00226
<a name="l00232"></a>00232 <span class="keywordtype">bool</span> operator>=(<span class="keyword">const</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>& timer);
<a name="l00233"></a>00233
<a name="l00238"></a>00238 <span class="keyword">static</span> <span class="keywordtype">void</span> sync(<a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a> &timer);
<a name="l00239"></a>00239 };
<a name="l00240"></a>00240
<a name="l00251"></a><a class="code" href="a00170.html">00251</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00170.html" title="A timer queue for timer events.">TimerQueue</a> : <span class="keyword">public</span> <a class="code" href="a00099.html" title="An index container for maintaining an ordered list of objects.">OrderedIndex</a>
<a name="l00252"></a>00252 {
<a name="l00253"></a>00253 <span class="keyword">public</span>:
<a name="l00262"></a><a class="code" href="a00171.html">00262</a> <span class="keyword">class </span>__EXPORT <a class="code" href="a00171.html" title="A timer event object that lives on a timer queue.">event</a> : <span class="keyword">protected</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a>, <span class="keyword">public</span> <a class="code" href="a00068.html" title="A double linked list object.">LinkedList</a>
<a name="l00263"></a>00263 {
<a name="l00264"></a>00264 <span class="keyword">protected</span>:
<a name="l00265"></a>00265 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="a00170.html" title="A timer queue for timer events.">TimerQueue</a>;
<a name="l00266"></a>00266
<a name="l00271"></a>00271 <a class="code" href="a00171.html" title="A timer event object that lives on a timer queue.">event</a>(<a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> expire);
<a name="l00272"></a>00272
<a name="l00278"></a>00278 <a class="code" href="a00171.html" title="A timer event object that lives on a timer queue.">event</a>(<a class="code" href="a00170.html" title="A timer queue for timer events.">TimerQueue</a> *<a class="code" href="a00109.html" title="Manage a thread-safe queue of objects through reference pointers.">queue</a>, <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> expire);
<a name="l00279"></a>00279
<a name="l00283"></a>00283 <span class="keyword">virtual</span> <span class="keywordtype">void</span> expired(<span class="keywordtype">void</span>) = 0;
<a name="l00284"></a>00284
<a name="l00290"></a>00290 <span class="keyword">virtual</span> <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout(<span class="keywordtype">void</span>);
<a name="l00291"></a>00291
<a name="l00292"></a>00292 <span class="keyword">public</span>:
<a name="l00296"></a>00296 <span class="keyword">virtual</span> ~<a class="code" href="a00171.html" title="A timer event object that lives on a timer queue.">event</a>();
<a name="l00297"></a>00297
<a name="l00303"></a>00303 <span class="keywordtype">void</span> attach(<a class="code" href="a00170.html" title="A timer queue for timer events.">TimerQueue</a> *queue);
<a name="l00304"></a>00304
<a name="l00308"></a>00308 <span class="keywordtype">void</span> detach(<span class="keywordtype">void</span>);
<a name="l00309"></a>00309
<a name="l00314"></a>00314 <span class="keywordtype">void</span> arm(<a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> timeout);
<a name="l00315"></a>00315
<a name="l00319"></a>00319 <span class="keywordtype">void</span> disarm(<span class="keywordtype">void</span>);
<a name="l00320"></a>00320
<a name="l00325"></a><a class="code" href="a00171.html#af159beceace1f1fa0b9cee679b4d4ea8">00325</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> isExpired(<span class="keywordtype">void</span>)
<a name="l00326"></a>00326 {<span class="keywordflow">return</span> Timer::isExpired();};
<a name="l00327"></a>00327
<a name="l00332"></a><a class="code" href="a00171.html#a053b5fa92f8c818b662880a998bb515d">00332</a> <span class="keyword">inline</span> <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> <span class="keyword">get</span>(void) <span class="keyword">const</span>
<a name="l00333"></a>00333 {<span class="keywordflow">return</span> Timer::get();};
<a name="l00334"></a>00334
<a name="l00338"></a>00338 <span class="keywordtype">void</span> update(<span class="keywordtype">void</span>);
<a name="l00339"></a>00339
<a name="l00344"></a><a class="code" href="a00171.html#ada75b5c938a4a7a53e2f7f2e2d7537df">00344</a> <span class="keyword">inline</span> <a class="code" href="a00170.html" title="A timer queue for timer events.">TimerQueue</a> *getQueue(<span class="keywordtype">void</span>)
<a name="l00345"></a>00345 {<span class="keywordflow">return</span> <span class="keyword">static_cast<</span><a class="code" href="a00170.html" title="A timer queue for timer events.">TimerQueue</a>*<span class="keyword">></span>(root);};
<a name="l00346"></a>00346 };
<a name="l00347"></a>00347
<a name="l00348"></a>00348 <span class="keyword">protected</span>:
<a name="l00349"></a>00349 <span class="keyword">friend</span> <span class="keyword">class </span>event;
<a name="l00350"></a>00350
<a name="l00355"></a>00355 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00214.html#afbca012752e5f641c92e06645f0c06dc" title="Convenience function to exclusively schedule conditional access.">modify</a>(<span class="keywordtype">void</span>) = 0;
<a name="l00356"></a>00356
<a name="l00362"></a>00362 <span class="keyword">virtual</span> <span class="keywordtype">void</span> update(<span class="keywordtype">void</span>) = 0;
<a name="l00363"></a>00363
<a name="l00364"></a>00364 <span class="keyword">public</span>:
<a name="l00368"></a>00368 <a class="code" href="a00170.html" title="A timer queue for timer events.">TimerQueue</a>();
<a name="l00369"></a>00369
<a name="l00373"></a>00373 <span class="keyword">virtual</span> ~<a class="code" href="a00170.html" title="A timer queue for timer events.">TimerQueue</a>();
<a name="l00374"></a>00374
<a name="l00379"></a>00379 <span class="keywordtype">void</span> <a class="code" href="a00068.html#aa1343f215617af84361213306ff7d8f2" title="Insert object behind our object.">operator+=</a>(event &timer);
<a name="l00380"></a>00380
<a name="l00385"></a>00385 <span class="keywordtype">void</span> <a class="code" href="a00068.html#a77b5fca123358eabd50e1ad68d85327e" title="Insert object in front of our object.">operator-=</a>(event &timer);
<a name="l00386"></a>00386
<a name="l00394"></a>00394 <a class="code" href="a00201.html#af412159e5cef839836a5e7b19ee75d1c" title="Typedef for millisecond timer values.">timeout_t</a> expire();
<a name="l00395"></a>00395 };
<a name="l00396"></a>00396
<a name="l00400"></a><a class="code" href="a00214.html#a8f22c1bab9fd1a61be57c65cf0d05148">00400</a> <span class="keyword">typedef</span> <a class="code" href="a00171.html" title="A timer event object that lives on a timer queue.">TimerQueue::event</a> <a class="code" href="a00171.html" title="A timer event object that lives on a timer queue.">TQEvent</a>;
<a name="l00401"></a>00401
<a name="l00405"></a><a class="code" href="a00214.html#a95971f0257cca8117f51a251f755cd1b">00405</a> <span class="keyword">typedef</span> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">Timer</a> <a class="code" href="a00169.html" title="Timer class to use when scheduling realtime events.">timer_t</a>;
<a name="l00406"></a>00406
<a name="l00407"></a>00407 END_NAMESPACE
<a name="l00408"></a>00408
<a name="l00409"></a>00409 <span class="keyword">extern</span> <span class="stringliteral">"C"</span> {
<a name="l00410"></a>00410 <span class="preprocessor">#if defined(WIN32)</span>
<a name="l00411"></a>00411 <span class="preprocessor"></span> __EXPORT <span class="keywordtype">int</span> gettimeofday(<span class="keyword">struct</span> timeval *tv, <span class="keywordtype">void</span> *tz);
<a name="l00412"></a>00412 <span class="preprocessor">#endif</span>
<a name="l00413"></a>00413 <span class="preprocessor"></span>}
<a name="l00414"></a>00414
<a name="l00415"></a>00415 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Tue Jul 6 08:22:01 2010 for UCommon by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
|