Zen API
 All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kTimer.h
Go to the documentation of this file.
1 
10 #ifndef K_API_TIMER_H
11 #define K_API_TIMER_H
12 
13 #include <kApi/kApiDef.h>
14 #include <kApi/Threads/kTimer.x.h>
15 
22 //typedef kObject kTimer; --forward-declared in kApiDef.x.h
23 
35 {
36  return kApiLib_TimerQueryHandler()();
37 }
38 
47 {
48  return ticks * kApiLib_TimerMultiplier() / kApiLib_TimerDivider();
49 }
50 
59 {
60  return kApiLib_TimerDivider() * time / kApiLib_TimerMultiplier();
61 }
62 
73 {
74  return kTimer_FromTicks(kTimer_Ticks());
75 }
76 
92 {
93  k64u startTime = kTimer_Now();
94 
95  while (kTimer_Now() < (startTime + duration));
96 
97  return kOK;
98 }
99 
108 kFx(kStatus) kTimer_Construct(kTimer* timer, kAlloc allocator);
109 
120 kFx(kStatus) kTimer_Start(kTimer timer, k64u totalTime);
121 
134 kFx(kStatus) kTimer_Stop(kTimer timer);
135 
143 kFx(kBool) kTimer_IsStarted(kTimer timer);
144 
152 kFx(kBool) kTimer_IsExpired(kTimer timer);
153 
161 kFx(k64u) kTimer_Elapsed(kTimer timer);
162 
170 kFx(k64u) kTimer_Remaining(kTimer timer);
171 
172 #endif
kStatus kTimer_Stop(kTimer timer)
Stops the timer.
Represents a 64-bit unsigned integer.
k64u kTimer_Ticks()
Provides the current time in underlying clock ticks.
Definition: kTimer.h:34
Abstract base class for memory allocator types.
kBool kTimer_IsExpired(kTimer timer)
Reports whether a count-down timer has expired.
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:29
k64u kTimer_Elapsed(kTimer timer)
Reports the duration, in microseconds, for which the timer has been running.
Core Zen type declarations.
k64u kTimer_FromTicks(k64u ticks)
Converts the specified number of clock ticks to microseconds.
Definition: kTimer.h:46
k64u kTimer_Now()
Provides the current time in microseconds.
Definition: kTimer.h:72
kBool kTimer_IsStarted(kTimer timer)
Reports whether a timer has been started.
k64u kTimer_Remaining(kTimer timer)
Reports the remaining time, in microseconds, for a countdown timer.
k64u kTimer_ToTicks(k64u time)
Converts the specified number of microseconds to clock ticks.
Definition: kTimer.h:58
k64u kTimer_Spin(k64u duration)
Performs CPU busywork for at least the specified duration.
Definition: kTimer.h:91
kStatus kTimer_Start(kTimer timer, k64u totalTime)
Starts the timer.
#define kOK
Operation successful.
Definition: kApiDef.h:543
Represents an error code.
kStatus kTimer_Construct(kTimer *timer, kAlloc allocator)
Constructs a timer object.
Represents a boolean value.
Represents an interval timer.