/[pearpc]/src/system/systimer.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /src/system/systimer.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Wed Sep 5 17:11:21 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 2623 byte(s)
import upstream CVS
1 /// @file systimer.h
2 /// @author Kimball Thurston
3 ///
4
5 //
6 // Copyright (c) 2004 Kimball Thurston
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License version 2 as
10 // published by the Free Software Foundation.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21
22 #ifndef _SYSTIMER_H_
23 #define _SYSTIMER_H_
24
25 #include <time.h>
26 #include "types.h"
27
28 typedef void *sys_timer;
29
30 /**
31 * Function that will be called when the timer expires
32 * @param t Expired timer.
33 */
34 typedef void (*sys_timer_callback)(sys_timer t);
35
36 /**
37 * @brief Creates a timer that can be used for high resolution callback.
38 *
39 * The timer has limited resolution unless the process has been made to
40 * be a realtime process, in which case accuracy down to 1 nanosecond is
41 * theoretically possible.
42 *
43 * @param t Pointer to a sys_timer to receive the timer. If the call fails,
44 * This value will be assigned NULL.
45 * @param cb_func Pointer to the callback function to call when the timer
46 * expires.
47 * @return true if the function succeeds and the timer is created, false
48 * otherwise.
49 */
50 bool sys_create_timer(sys_timer *t, sys_timer_callback cb_func);
51
52 /**
53 * Free resources associated with the given timer
54 *
55 * @param t Timer to delete.
56 */
57 void sys_delete_timer(sys_timer t);
58
59 /**
60 * @brief Resets the timer to expire in the given time.
61 *
62 * Time is relative to the current time, so in @a secs seconds and
63 * @a nanosecs, the timer will expire and call the callback given
64 * when the timer was created as soon as the process is scheduled by
65 * the host operating system.
66 * Setting the timer when it is already arm has the effect of resetting
67 * the timer.
68 *
69 * @param t Timer to set.
70 * @param secs Number of seconds before the timer should expire.
71 * @param nanosecs Number of nanoseconds before the timer should expire.
72 * @param periodic If true, the timer is made periodic.
73 */
74 void sys_set_timer(sys_timer t, time_t secs, long int nanosecs, bool periodic);
75
76 /**
77 * Retrieve the accuracy of the timer in nanoseconds.
78 *
79 * @return resolution in nanoseconds, 0 on error.
80 */
81 uint64 sys_get_timer_resolution(sys_timer t);
82
83 #endif /* _SYSTIMER_H_ */

  ViewVC Help
Powered by ViewVC 1.1.26