1 |
michael |
3251 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 |
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
3 |
|
|
<title>PEAK Library: Timer</title> |
4 |
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css"> |
5 |
|
|
</head><body> |
6 |
|
|
<!-- Generated by Doxygen 1.3.5 --> |
7 |
|
|
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="functions.html">Data Fields</a></div> |
8 |
|
|
<h1>Timer</h1><hr><a name="_details"></a><h2>Detailed Description</h2> |
9 |
|
|
Lightweight timer/repeater support within a task. Units are floats in seconds with an internal precision up to usec, but subjects to client's event handlers so don't expect a lot.<br> |
10 |
|
|
For best results, please use in conjunction with the Time module (<code>peak_time*</code>). |
11 |
|
|
<p> |
12 |
|
|
<table border=0 cellpadding=0 cellspacing=0> |
13 |
|
|
<tr><td></td></tr> |
14 |
|
|
<tr><td colspan=2><br><h2>Typedefs</h2></td></tr> |
15 |
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="ga0" doxytag="timer::peak_timer" ></a> |
16 |
|
|
typedef __peak_timer * </td><td class="memItemRight" valign=bottom><a class="el" href="group__timer.html#ga0">peak_timer</a></td></tr> |
17 |
|
|
|
18 |
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Opaque timer pointer type. <br><br></td></tr> |
19 |
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="anchor" name="ga1" doxytag="timer::peak_timer_callback" ></a> |
20 |
|
|
typedef void(* </td><td class="memItemRight" valign=bottom><a class="el" href="group__timer.html#ga1">peak_timer_callback</a> )(<a class="el" href="group__timer.html#ga0">peak_timer</a> t, void *context)</td></tr> |
21 |
|
|
|
22 |
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Timer callback. <br><br></td></tr> |
23 |
|
|
<tr><td colspan=2><br><h2>Functions</h2></td></tr> |
24 |
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="group__timer.html#ga0">peak_timer</a> </td><td class="memItemRight" valign=bottom><a class="el" href="group__timer.html#ga2">peak_timer_create</a> (double fire, double interval, <a class="el" href="group__timer.html#ga1">peak_timer_callback</a> callout, void *context)</td></tr> |
25 |
|
|
|
26 |
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create a timer. <a href="#ga2"></a><br><br></td></tr> |
27 |
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="group__timer.html#ga3">peak_timer_configure</a> (<a class="el" href="group__timer.html#ga0">peak_timer</a> t, double fire, double interval)</td></tr> |
28 |
|
|
|
29 |
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">(Re)configure a timer. <a href="#ga3"></a><br><br></td></tr> |
30 |
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>double </td><td class="memItemRight" valign=bottom><a class="el" href="group__timer.html#ga4">peak_timer_get_firetime</a> (<a class="el" href="group__timer.html#ga0">peak_timer</a> t)</td></tr> |
31 |
|
|
|
32 |
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Get timer's fire date time. <a href="#ga4"></a><br><br></td></tr> |
33 |
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>double </td><td class="memItemRight" valign=bottom><a class="el" href="group__timer.html#ga5">peak_timer_get_interval</a> (<a class="el" href="group__timer.html#ga0">peak_timer</a> t)</td></tr> |
34 |
|
|
|
35 |
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Get timer's repeat-interval time. <a href="#ga5"></a><br><br></td></tr> |
36 |
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>void * </td><td class="memItemRight" valign=bottom><a class="el" href="group__timer.html#ga6">peak_timer_get_context</a> (<a class="el" href="group__timer.html#ga0">peak_timer</a> t)</td></tr> |
37 |
|
|
|
38 |
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Get timer's extra application-defined context. <a href="#ga6"></a><br><br></td></tr> |
39 |
|
|
<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="group__timer.html#ga7">peak_timer_set_context</a> (<a class="el" href="group__timer.html#ga0">peak_timer</a> t, void *context)</td></tr> |
40 |
|
|
|
41 |
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Change the context pointer of a timer. <a href="#ga7"></a><br><br></td></tr> |
42 |
|
|
</table> |
43 |
|
|
<hr><h2>Function Documentation</h2> |
44 |
|
|
<a class="anchor" name="ga3" doxytag="timer.h::peak_timer_configure" ></a><p> |
45 |
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
46 |
|
|
<tr> |
47 |
|
|
<td class="mdRow"> |
48 |
|
|
<table cellpadding="0" cellspacing="0" border="0"> |
49 |
|
|
<tr> |
50 |
|
|
<td class="md" nowrap valign="top"> void peak_timer_configure </td> |
51 |
|
|
<td class="md" valign="top">( </td> |
52 |
|
|
<td class="md" nowrap valign="top"><a class="el" href="group__timer.html#ga0">peak_timer</a> </td> |
53 |
|
|
<td class="mdname" nowrap> <em>t</em>, </td> |
54 |
|
|
</tr> |
55 |
|
|
<tr> |
56 |
|
|
<td></td> |
57 |
|
|
<td></td> |
58 |
|
|
<td class="md" nowrap>double </td> |
59 |
|
|
<td class="mdname" nowrap> <em>fire</em>, </td> |
60 |
|
|
</tr> |
61 |
|
|
<tr> |
62 |
|
|
<td></td> |
63 |
|
|
<td></td> |
64 |
|
|
<td class="md" nowrap>double </td> |
65 |
|
|
<td class="mdname" nowrap> <em>interval</em></td> |
66 |
|
|
</tr> |
67 |
|
|
<tr> |
68 |
|
|
<td></td> |
69 |
|
|
<td class="md">) </td> |
70 |
|
|
<td class="md" colspan="2"></td> |
71 |
|
|
</tr> |
72 |
|
|
|
73 |
|
|
</table> |
74 |
|
|
</td> |
75 |
|
|
</tr> |
76 |
|
|
</table> |
77 |
|
|
<table cellspacing=5 cellpadding=0 border=0> |
78 |
|
|
<tr> |
79 |
|
|
<td> |
80 |
|
|
|
81 |
|
|
</td> |
82 |
|
|
<td> |
83 |
|
|
|
84 |
|
|
<p> |
85 |
|
|
(Re)configure a timer. |
86 |
|
|
<p> |
87 |
|
|
<dl compact><dt><b>Parameters:</b></dt><dd> |
88 |
|
|
<table border="0" cellspacing="2" cellpadding="0"> |
89 |
|
|
<tr><td valign=top><em>t</em> </td><td>The timer reference to configure. </td></tr> |
90 |
|
|
<tr><td valign=top><em>fire</em> </td><td>Relative fire time in second. 0 means immediate fire (as soon as possible, usually during the next event loop). A value of -1.0 means never fire, and can be useful to temporarily "disable" a timer. </td></tr> |
91 |
|
|
<tr><td valign=top><em>interval</em> </td><td>Repeat interval in second. Use -1.0 for a one-shot timer. Value must be strictly positive for repeating timer. </td></tr> |
92 |
|
|
</table> |
93 |
|
|
</dl> |
94 |
|
|
</td> |
95 |
|
|
</tr> |
96 |
|
|
</table> |
97 |
|
|
<a class="anchor" name="ga2" doxytag="timer.h::peak_timer_create" ></a><p> |
98 |
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
99 |
|
|
<tr> |
100 |
|
|
<td class="mdRow"> |
101 |
|
|
<table cellpadding="0" cellspacing="0" border="0"> |
102 |
|
|
<tr> |
103 |
|
|
<td class="md" nowrap valign="top"> <a class="el" href="group__timer.html#ga0">peak_timer</a> peak_timer_create </td> |
104 |
|
|
<td class="md" valign="top">( </td> |
105 |
|
|
<td class="md" nowrap valign="top">double </td> |
106 |
|
|
<td class="mdname" nowrap> <em>fire</em>, </td> |
107 |
|
|
</tr> |
108 |
|
|
<tr> |
109 |
|
|
<td></td> |
110 |
|
|
<td></td> |
111 |
|
|
<td class="md" nowrap>double </td> |
112 |
|
|
<td class="mdname" nowrap> <em>interval</em>, </td> |
113 |
|
|
</tr> |
114 |
|
|
<tr> |
115 |
|
|
<td></td> |
116 |
|
|
<td></td> |
117 |
|
|
<td class="md" nowrap><a class="el" href="group__timer.html#ga1">peak_timer_callback</a> </td> |
118 |
|
|
<td class="mdname" nowrap> <em>callout</em>, </td> |
119 |
|
|
</tr> |
120 |
|
|
<tr> |
121 |
|
|
<td></td> |
122 |
|
|
<td></td> |
123 |
|
|
<td class="md" nowrap>void * </td> |
124 |
|
|
<td class="mdname" nowrap> <em>context</em></td> |
125 |
|
|
</tr> |
126 |
|
|
<tr> |
127 |
|
|
<td></td> |
128 |
|
|
<td class="md">) </td> |
129 |
|
|
<td class="md" colspan="2"></td> |
130 |
|
|
</tr> |
131 |
|
|
|
132 |
|
|
</table> |
133 |
|
|
</td> |
134 |
|
|
</tr> |
135 |
|
|
</table> |
136 |
|
|
<table cellspacing=5 cellpadding=0 border=0> |
137 |
|
|
<tr> |
138 |
|
|
<td> |
139 |
|
|
|
140 |
|
|
</td> |
141 |
|
|
<td> |
142 |
|
|
|
143 |
|
|
<p> |
144 |
|
|
Create a timer. |
145 |
|
|
<p> |
146 |
|
|
Note that the timer isn't activated until you add it to the task of your choice (usually <a class="el" href="group__task__common.html#ga8">peak_task_self()</a>) with <a class="el" href="group__task__timer.html#ga24">peak_task_timer_add()</a>.<p> |
147 |
|
|
<dl compact><dt><b>Parameters:</b></dt><dd> |
148 |
|
|
<table border="0" cellspacing="2" cellpadding="0"> |
149 |
|
|
<tr><td valign=top><em>fire</em> </td><td>Relative fire time in second. 0 means immediate fire (as soon as possible, usually during the next event loop). A value of -1.0 means never fire, and can be useful to temporarily "disable" a timer. </td></tr> |
150 |
|
|
<tr><td valign=top><em>interval</em> </td><td>Repeat interval in second. Use -1.0 for a one-shot timer. Value must be strictly positive for repeating timer. </td></tr> |
151 |
|
|
<tr><td valign=top><em>callout</em> </td><td>A pointer to your timer callback function which is triggered when the timer fires. </td></tr> |
152 |
|
|
<tr><td valign=top><em>context</em> </td><td>An extra application-defined pointer that will be passed to your timer callback function (it's not used by the library).</td></tr> |
153 |
|
|
</table> |
154 |
|
|
</dl> |
155 |
|
|
<dl compact><dt><b>Returns:</b></dt><dd>A newly allocated <code>peak_timer</code> reference or <code>NULL</code> if the timer cannot be created. </dd></dl> |
156 |
|
|
</td> |
157 |
|
|
</tr> |
158 |
|
|
</table> |
159 |
|
|
<a class="anchor" name="ga6" doxytag="timer.h::peak_timer_get_context" ></a><p> |
160 |
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
161 |
|
|
<tr> |
162 |
|
|
<td class="mdRow"> |
163 |
|
|
<table cellpadding="0" cellspacing="0" border="0"> |
164 |
|
|
<tr> |
165 |
|
|
<td class="md" nowrap valign="top"> void* peak_timer_get_context </td> |
166 |
|
|
<td class="md" valign="top">( </td> |
167 |
|
|
<td class="md" nowrap valign="top"><a class="el" href="group__timer.html#ga0">peak_timer</a> </td> |
168 |
|
|
<td class="mdname1" valign="top" nowrap> <em>t</em> </td> |
169 |
|
|
<td class="md" valign="top"> ) </td> |
170 |
|
|
<td class="md" nowrap></td> |
171 |
|
|
</tr> |
172 |
|
|
|
173 |
|
|
</table> |
174 |
|
|
</td> |
175 |
|
|
</tr> |
176 |
|
|
</table> |
177 |
|
|
<table cellspacing=5 cellpadding=0 border=0> |
178 |
|
|
<tr> |
179 |
|
|
<td> |
180 |
|
|
|
181 |
|
|
</td> |
182 |
|
|
<td> |
183 |
|
|
|
184 |
|
|
<p> |
185 |
|
|
Get timer's extra application-defined context. |
186 |
|
|
<p> |
187 |
|
|
<dl compact><dt><b>Parameters:</b></dt><dd> |
188 |
|
|
<table border="0" cellspacing="2" cellpadding="0"> |
189 |
|
|
<tr><td valign=top><em>t</em> </td><td>The timer reference.</td></tr> |
190 |
|
|
</table> |
191 |
|
|
</dl> |
192 |
|
|
<dl compact><dt><b>Returns:</b></dt><dd>Context pointer. </dd></dl> |
193 |
|
|
</td> |
194 |
|
|
</tr> |
195 |
|
|
</table> |
196 |
|
|
<a class="anchor" name="ga4" doxytag="timer.h::peak_timer_get_firetime" ></a><p> |
197 |
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
198 |
|
|
<tr> |
199 |
|
|
<td class="mdRow"> |
200 |
|
|
<table cellpadding="0" cellspacing="0" border="0"> |
201 |
|
|
<tr> |
202 |
|
|
<td class="md" nowrap valign="top"> double peak_timer_get_firetime </td> |
203 |
|
|
<td class="md" valign="top">( </td> |
204 |
|
|
<td class="md" nowrap valign="top"><a class="el" href="group__timer.html#ga0">peak_timer</a> </td> |
205 |
|
|
<td class="mdname1" valign="top" nowrap> <em>t</em> </td> |
206 |
|
|
<td class="md" valign="top"> ) </td> |
207 |
|
|
<td class="md" nowrap></td> |
208 |
|
|
</tr> |
209 |
|
|
|
210 |
|
|
</table> |
211 |
|
|
</td> |
212 |
|
|
</tr> |
213 |
|
|
</table> |
214 |
|
|
<table cellspacing=5 cellpadding=0 border=0> |
215 |
|
|
<tr> |
216 |
|
|
<td> |
217 |
|
|
|
218 |
|
|
</td> |
219 |
|
|
<td> |
220 |
|
|
|
221 |
|
|
<p> |
222 |
|
|
Get timer's fire date time. |
223 |
|
|
<p> |
224 |
|
|
<dl compact><dt><b>Parameters:</b></dt><dd> |
225 |
|
|
<table border="0" cellspacing="2" cellpadding="0"> |
226 |
|
|
<tr><td valign=top><em>t</em> </td><td>The timer reference.</td></tr> |
227 |
|
|
</table> |
228 |
|
|
</dl> |
229 |
|
|
<dl compact><dt><b>Returns:</b></dt><dd>Absolute time in second before the timer fires (if it is added to a task). </dd></dl> |
230 |
|
|
</td> |
231 |
|
|
</tr> |
232 |
|
|
</table> |
233 |
|
|
<a class="anchor" name="ga5" doxytag="timer.h::peak_timer_get_interval" ></a><p> |
234 |
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
235 |
|
|
<tr> |
236 |
|
|
<td class="mdRow"> |
237 |
|
|
<table cellpadding="0" cellspacing="0" border="0"> |
238 |
|
|
<tr> |
239 |
|
|
<td class="md" nowrap valign="top"> double peak_timer_get_interval </td> |
240 |
|
|
<td class="md" valign="top">( </td> |
241 |
|
|
<td class="md" nowrap valign="top"><a class="el" href="group__timer.html#ga0">peak_timer</a> </td> |
242 |
|
|
<td class="mdname1" valign="top" nowrap> <em>t</em> </td> |
243 |
|
|
<td class="md" valign="top"> ) </td> |
244 |
|
|
<td class="md" nowrap></td> |
245 |
|
|
</tr> |
246 |
|
|
|
247 |
|
|
</table> |
248 |
|
|
</td> |
249 |
|
|
</tr> |
250 |
|
|
</table> |
251 |
|
|
<table cellspacing=5 cellpadding=0 border=0> |
252 |
|
|
<tr> |
253 |
|
|
<td> |
254 |
|
|
|
255 |
|
|
</td> |
256 |
|
|
<td> |
257 |
|
|
|
258 |
|
|
<p> |
259 |
|
|
Get timer's repeat-interval time. |
260 |
|
|
<p> |
261 |
|
|
<dl compact><dt><b>Parameters:</b></dt><dd> |
262 |
|
|
<table border="0" cellspacing="2" cellpadding="0"> |
263 |
|
|
<tr><td valign=top><em>t</em> </td><td>The timer reference.</td></tr> |
264 |
|
|
</table> |
265 |
|
|
</dl> |
266 |
|
|
<dl compact><dt><b>Returns:</b></dt><dd>Interval time in second. </dd></dl> |
267 |
|
|
</td> |
268 |
|
|
</tr> |
269 |
|
|
</table> |
270 |
|
|
<a class="anchor" name="ga7" doxytag="timer.h::peak_timer_set_context" ></a><p> |
271 |
|
|
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
272 |
|
|
<tr> |
273 |
|
|
<td class="mdRow"> |
274 |
|
|
<table cellpadding="0" cellspacing="0" border="0"> |
275 |
|
|
<tr> |
276 |
|
|
<td class="md" nowrap valign="top"> void peak_timer_set_context </td> |
277 |
|
|
<td class="md" valign="top">( </td> |
278 |
|
|
<td class="md" nowrap valign="top"><a class="el" href="group__timer.html#ga0">peak_timer</a> </td> |
279 |
|
|
<td class="mdname" nowrap> <em>t</em>, </td> |
280 |
|
|
</tr> |
281 |
|
|
<tr> |
282 |
|
|
<td></td> |
283 |
|
|
<td></td> |
284 |
|
|
<td class="md" nowrap>void * </td> |
285 |
|
|
<td class="mdname" nowrap> <em>context</em></td> |
286 |
|
|
</tr> |
287 |
|
|
<tr> |
288 |
|
|
<td></td> |
289 |
|
|
<td class="md">) </td> |
290 |
|
|
<td class="md" colspan="2"></td> |
291 |
|
|
</tr> |
292 |
|
|
|
293 |
|
|
</table> |
294 |
|
|
</td> |
295 |
|
|
</tr> |
296 |
|
|
</table> |
297 |
|
|
<table cellspacing=5 cellpadding=0 border=0> |
298 |
|
|
<tr> |
299 |
|
|
<td> |
300 |
|
|
|
301 |
|
|
</td> |
302 |
|
|
<td> |
303 |
|
|
|
304 |
|
|
<p> |
305 |
|
|
Change the context pointer of a timer. |
306 |
|
|
<p> |
307 |
|
|
<dl compact><dt><b>Parameters:</b></dt><dd> |
308 |
|
|
<table border="0" cellspacing="2" cellpadding="0"> |
309 |
|
|
<tr><td valign=top><em>t</em> </td><td>The timer reference. </td></tr> |
310 |
|
|
<tr><td valign=top><em>context</em> </td><td>An extra application-defined pointer that will be passed to your timer callback function (it's not used by the library). </td></tr> |
311 |
|
|
</table> |
312 |
|
|
</dl> |
313 |
|
|
</td> |
314 |
|
|
</tr> |
315 |
|
|
</table> |
316 |
|
|
<hr size="1"><address style="align: right;"><small>Generated on Sat Jan 17 21:41:54 2004 for the PEAK Library by |
317 |
|
|
<a href="http://www.doxygen.org/index.html"> |
318 |
|
|
<img src="doxygen.png" alt="doxygen" align="middle" border="0" > |
319 |
|
|
</a></small> <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=98146&type=1" width="88" height="31" align="middle" border="0" alt="SourceForge.net Logo" /></a></address> |
320 |
|
|
</body> |
321 |
|
|
</html> |
322 |
|
|
|