5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2007 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 /****h* silcutil/SILC Timer Interface
22 * SILC Timer interface provides a simple way to measure time intervals.
23 * The SILC Timer works with microsecond resolution, depending on platform.
30 /****s* silcutil/SilcTimerAPI/SilcTimer
34 * typedef struct SilcTimerObject *SilcTimer, SilcTimerStruct;
38 * The timer context. The context is given as argument to all
39 * silc_timer_* functions.
42 typedef struct SilcTimerObject *SilcTimer, SilcTimerStruct;
44 /****f* silcutil/SilcTimerAPI/silc_timer_start
48 * SilcBool silc_timer_start(SilcTimer timer);
52 * Starts the timer. If the timer is already running this will reset
53 * the timer and continue.
57 * SilcTimerStruct timer;
59 * silc_timer_start(&timer);
61 * silc_timer_stop(&timer);
62 * silc_timer_value(&timer, &elapsed_sec, &elapsed_usec);
65 void silc_timer_start(SilcTimer timer);
67 /****f* silcutil/SilcTimerAPI/silc_timer_stop
71 * void silc_timer_stop(SilcTimer timer);
75 * Stop the timer. The elapsed time can be retrieved by calling the
76 * silc_timer_value function.
79 void silc_timer_stop(SilcTimer timer);
81 /****f* silcutil/SilcTimerAPI/silc_timer_continue
85 * void silc_timer_continue(SilcTimer timer);
89 * Continue stopped timer. If timer is running already this does nothing.
92 void silc_timer_continue(SilcTimer timer);
94 /****f* silcutil/SilcTimerAPI/silc_timer_value
98 * void silc_timer_value(SilcTimer timer,
99 * SilcUInt64 *elapsed_time_seconds,
100 * SilcUInt32 *elapsed_time_microseconds);
104 * Returns either the current value or the end value of the timer. If the
105 * timer is currently running this returns the currently elapsed time. If
106 * the timer is stopped this returns the cumulative elapsed time.
109 void silc_timer_value(SilcTimer timer,
110 SilcUInt64 *elapsed_time_seconds,
111 SilcUInt32 *elapsed_time_microseconds);
113 /****f* silcutil/SilcTimerAPI/silc_timer_value_time
117 * void silc_timer_value_time(SilcTimer timer, SilcTime ret_time);
121 * Same as silc_timer_value but returns the elapsed time to `ret_time'
122 * SilcTime structure as absolute date and time. This is useful if the
123 * returned time needs to be converted into some other format such as
124 * time and date strings.
127 void silc_timer_value_time(SilcTimer timer, SilcTime ret_time);
129 /****f* silcutil/SilcTimerAPI/silc_timer_start_time
133 * void silc_timer_start_time(SilcTimer timer, SilcTime ret_start_time);
137 * Returns the timer's start time into `ret_start_time' SilcTime structure.
140 void silc_timer_start_time(SilcTimer timer, SilcTime ret_start_time);
142 /****f* silcutil/SilcTimerAPI/silc_timer_is_running
146 * SilcBool silc_timer_is_running(SilcTimer timer);
150 * Returns TRUE if the timer is currently running, FALSE otherwise.
153 SilcBool silc_timer_is_running(SilcTimer timer);
155 #include "silctimer_i.h"
157 #endif /* SILCTIMER_H */