Function yield [src]
Yields the current thread potentially allowing other threads to run.
Prototype
pub fn yield() YieldError!void
Possible Errors
The system is not configured to allow yielding
Source
pub fn yield() YieldError!void {
if (native_os == .windows) {
// The return value has to do with how many other threads there are; it is not
// an error condition on Windows.
_ = windows.kernel32.SwitchToThread();
return;
}
switch (posix.errno(posix.system.sched_yield())) {
.SUCCESS => return,
.NOSYS => return error.SystemCannotYield,
else => return error.SystemCannotYield,
}
}