time: yield accurate_sleep instead of relaxing the cpu

This commit is contained in:
hikari
2022-04-16 14:08:37 +03:00
parent b9dc81d808
commit 0a0440a6e8
3 changed files with 18 additions and 2 deletions
+6
View File
@@ -1,6 +1,8 @@
//+build linux, darwin, freebsd, openbsd
package time
import "core:sys/unix"
IS_SUPPORTED :: true // NOTE: Times on Darwin are UTC.
when ODIN_OS == .Darwin {
@@ -17,6 +19,10 @@ foreign libc {
@(link_name="nanosleep") _unix_nanosleep :: proc(requested: ^TimeSpec, remaining: ^TimeSpec) -> i32 ---
}
_yield :: proc "contextless" () {
unix.sched_yield()
}
TimeSpec :: struct {
tv_sec : i64, /* seconds */
tv_nsec : i64, /* nanoseconds */