| 1234567891011121314151617 |
- import CSystem
- extension ArkSys {
- public struct Time {
- /// Returns the current monotonic timestamp in milliseconds.
- public static func currentMs() -> UInt64 {
- var ts = timespec()
- clock_gettime(CLOCK_MONOTONIC, &ts)
- return UInt64(ts.tv_sec) * 1000 + UInt64(ts.tv_nsec) / 1_000_000
- }
-
- /// Suspends the current thread for the specified number of milliseconds.
- public static func sleep(ms: UInt64) {
- usleep(useconds_t(ms * 1000))
- }
- }
- }
|