use crate::{AmountReturned, LuaState, ffi};
impl LuaState {
#[inline]
#[must_use]
pub fn is_thread(&self, index: i32) -> bool {
unsafe { ffi::lua_isthread(self.as_ptr(), index) != 0 }
}
#[inline]
#[must_use]
pub fn is_main_thread(&self) -> bool {
unsafe { self.access_mut(|lua| {
let main = lua.push_thread();
lua.pop_unchecked(1);
main
}) }
}
#[inline]
pub fn push_thread(&mut self) -> bool {
unsafe { ffi::lua_pushthread(self.as_ptr()) != 0 }
}
#[inline]
pub fn yield_any(self, amount: i32) -> AmountReturned {
unsafe { AmountReturned::unchecked(ffi::lua_yield(self.as_ptr(), amount)) }
}
}