wasmer_wasix/syscalls/wasix/sched_yield.rs
1use super::*;
2use crate::syscalls::*;
3
4/// ### `sched_yield()`
5/// Yields execution of the thread
6#[instrument(level = "trace", skip_all, ret)]
7pub fn sched_yield<M: MemorySize + 'static>(
8 mut ctx: FunctionEnvMut<'_, WasiEnv>,
9) -> Result<Errno, WasiError> {
10 WasiEnv::do_pending_operations(&mut ctx)?;
11
12 ctx = wasi_try_ok!(maybe_backoff::<M>(ctx)?);
13
14 //trace!("wasi[{}:{}]::sched_yield", ctx.data().pid(), ctx.data().tid());
15 thread_sleep_internal::<M>(ctx, 0)
16}