use std::sync::Arc;
use imbl::vector;
use crate::{model::{stof_std::{SLEEP, STD_LIB}, LibFunc, Param}, runtime::{instruction::Instructions, instructions::Base, Num, NumT, Type, Val}};
pub fn stof_sleep() -> LibFunc {
LibFunc {
library: STD_LIB.clone(),
name: "sleep".into(),
is_async: false,
docs: r#"# Std.sleep(time: ms) -> void
Instruct this process to sleep for an amount of time, while others continue executing. Use time units for specificity, but don't expect this to be very accurate (guaranteed it will sleep for at least this long, but maybe longer). Default unit is milliseconds.
```rust
sleep(1s); // sleep for 1 second
```
"#.into(),
params: vector![
Param { name: "time".into(), param_type: Type::Num(NumT::Float), default: Some(Arc::new(Base::Literal(Val::Num(Num::Float(1000.))))) }
],
return_type: None,
unbounded_args: false,
args_to_symbol_table: false,
func: Arc::new(|_as_ref, _arg_count, _env, _graph| {
let mut instructions = Instructions::default();
instructions.push(SLEEP.clone());
Ok(instructions)
})
}
}