Zen API

- Home
- Help Topics
- Types by Category
- All Types
- Files

All Classes Files Functions Variables Typedefs Macros Groups Pages
kTimer.h
Go to the documentation of this file.
1 /**
2 * @file kTimer.h
3 * @brief Declares the kTimer class.
4 *
5 * @internal
6 * Copyright (C) 2005-2014 by LMI Technologies Inc.
7 * Licensed under the MIT License.
8 * Redistributed files must retain the above copyright notice.
9 */
10 #ifndef K_API_TIMER_H
11 #define K_API_TIMER_H
12
13 #include <kApi/kApiDef.h>
14
15 kBeginHeader()
16
17 /**
18 * @class kTimer
19 * @extends kObject
20 * @ingroup kApi-Threads
21 * @brief Represents an interval timer.
22 */
23 //typedef kObject kTimer; --forward-declared in kApiDef.x.h
24
25 /**
26 * Provides the current time in microseconds.
27 *
28 * This function provides a time value in microseconds; successive calls to this function can be
29 * used to measure a time interval.
30 *
31 * @public @memberof kTimer
32 * @return Current time, in microseconds.
33 */
34 kFx(k64u) kTimer_Now();
35
36 /**
37 * Constructs a timer object.
38 *
39 * @public @memberof kTimer
40 * @param timer Destination for the constructed object handle.
41 * @param allocator Memory allocator (or kNULL for default).
42 * @return Operation status.
43 */
44 kFx(kStatus) kTimer_Construct(kTimer* timer, kAlloc allocator);
45
46 /**
47 * Starts the timer.
48 *
49 * If the timer will be used to count up, rather than count down, totalTime can be zero.
50 *
51 * @public @memberof kTimer
52 * @param timer Timer object.
53 * @param totalTime Total time to count down, in microseconds.
54 * @return Operation status.
55 */
56 kFx(kStatus) kTimer_Start(kTimer timer, k64u totalTime);
57
58 /**
59 * Stops the timer.
60 *
61 * kTimer_Elapsed can be used to report the time between start and stop.
62 *
63 * The use of kTimer_Stop is strictly optional; it is not necessary to call kTimer_Stop for each
64 * invocation of kTimer_Start.
65 *
66 * @public @memberof kTimer
67 * @param timer Timer object.
68 * @return Operation status.
69 */
70 kFx(kStatus) kTimer_Stop(kTimer timer);
71
72 /**
73 * Reports whether a timer has been started.
74 *
75 * @public @memberof kTimer
76 * @param timer Timer object.
77 * @return kTRUE if the timer was started.
78 */
79 kFx(kBool) kTimer_IsStarted(kTimer timer);
80
81 /**
82 * Reports whether a count-down timer has expired.
83 *
84 * @public @memberof kTimer
85 * @param timer Timer object.
86 * @return kTRUE if the timer has expired.
87 */
88 kFx(kBool) kTimer_IsExpired(kTimer timer);
89
90 /**
91 * Reports the duration, in microseconds, for which the timer has been running.
92 *
93 * @public @memberof kTimer
94 * @param timer Timer object.
95 * @return Elapsed time, in microseconds.
96 */
97 kFx(k64u) kTimer_Elapsed(kTimer timer);
98
99 /**
100 * Reports the remaining time, in microseconds, for a countdown timer.
101 *
102 * @public @memberof kTimer
103 * @param timer Timer object.
104 * @return Remaining time, in microseconds.
105 */
106 kFx(k64u) kTimer_Remaining(kTimer timer);
107
108 kEndHeader()
109
110 #include <kApi/Threads/kTimer.x.h>
111
112 #endif
k64u
Represents a 64-bit unsigned integer.
kAlloc
Abstract base class for memory allocator types.
kTimer::kTimer_IsExpired
kBool kTimer_IsExpired(kTimer timer)
Reports whether a count-down timer has expired.
kApiDef.h
Essential API declarations.
kTimer::kTimer_Stop
kStatus kTimer_Stop(kTimer timer)
Stops the timer.
kTimer::kTimer_Remaining
k64u kTimer_Remaining(kTimer timer)
Reports the remaining time, in microseconds, for a countdown timer.
kTimer::kTimer_Start
kStatus kTimer_Start(kTimer timer, k64u totalTime)
Starts the timer.
kTimer::kTimer_IsStarted
kBool kTimer_IsStarted(kTimer timer)
Reports whether a timer has been started.
kStatus
Represents an enumeration of error codes.
kTimer::kTimer_Construct
kStatus kTimer_Construct(kTimer *timer, kAlloc allocator)
Constructs a timer object.
kBool
Represents a boolean value.
kTimer::kTimer_Elapsed
k64u kTimer_Elapsed(kTimer timer)
Reports the duration, in microseconds, for which the timer has been running.
kTimer
Represents an interval timer.
kTimer::kTimer_Now
k64u kTimer_Now()
Provides the current time in microseconds.
kPeriodic
Provides a periodic function call.