//! `thread` on WASI: there is one thread.
use crate::{ErrorKind, Result};
pub(crate) const NAME_MAX: usize = 0;
#[link(wasm_import_module = "wasi_snapshot_preview1")]
unsafe extern "C" {
fn sched_yield() -> i32;
}
pub(crate) fn id() -> u64 {
1
}
pub(crate) fn yield_now() {
// SAFETY: sched_yield takes nothing. Its only outcome of interest is
// that the host got to run something else.
let _ = unsafe { sched_yield() };
}
pub(crate) fn available_parallelism() -> Result<usize> {
Ok(1)
}
pub(crate) fn set_name(_name: &str) -> Result<()> {
Err(ErrorKind::Unsupported.into())
}
pub(crate) fn name(_buf: &mut [u8]) -> Result<usize> {
Err(ErrorKind::Unsupported.into())
}