mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
time: yield accurate_sleep instead of relaxing the cpu
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user