distant/distant-lua-tests/tests/common/poll.rs
Chip Senkbeil 16bed4690b
Add lua lib & support compiling distant cli on windows (#59)
* Update distant-ssh2 with new changes to wezterm-ssh
* Implement lua module (distant-lua)
* Implement tests for lua module (distant-lua-tests)
* Add untested windows daemon support
* distant binary now compiles on windows
* Split up Github actions for Windows, MacOS, and Linux into individual yaml files
2021-10-06 23:17:07 -05:00

18 lines
437 B
Rust

use mlua::{chunk, prelude::*};
use std::{thread, time::Duration};
/// Creates a function that can be passed as the schedule function for `wrap_async`
pub fn make_function(lua: &Lua) -> LuaResult<LuaFunction> {
let sleep = lua.create_function(|_, ()| {
thread::sleep(Duration::from_millis(10));
Ok(())
})?;
lua.load(chunk! {
local cb = ...
$sleep()
cb()
})
.into_function()
}