hos/src/hulk/time.d

43 lines
709 B
D

/**
* Time functionality.
*/
module hulk.time;
import core.volatile;
struct Time
{
/** System uptime (ms). */
private static __gshared ulong s_uptime;
/**
* Millisecond ISR.
*/
public static void ms_isr()
{
s_uptime++;
}
/**
* Get system uptime (ms).
*/
public static @property ulong uptime()
{
return volatileLoad(&s_uptime);
}
/**
* Sleep for the given amount of time (ms).
*
* @param count
* Number of milliseconds to sleep for.
*/
public static void msleep(ulong count)
{
ulong wait_for = uptime() + count + 1;
while (uptime() < wait_for)
{
}
}
}