use luau_vm::Thread as VmThread;
use crate::lua::runtime::RuntimeData;
use crate::thread::Thread;
#[derive(Clone, Copy)]
pub struct LuaRef<'lua> {
thread: &'lua VmThread,
runtime: &'lua RuntimeData,
}
impl<'lua> LuaRef<'lua> {
pub(crate) const fn new(thread: &'lua VmThread, runtime: &'lua RuntimeData) -> Self {
Self { thread, runtime }
}
pub fn current_thread(&self) -> Thread<'lua> {
Thread::new(self.thread, self.runtime)
}
pub(crate) const fn as_vm(&self) -> &'lua VmThread {
self.thread
}
pub(crate) const fn runtime(&self) -> &'lua RuntimeData {
self.runtime
}
pub fn is_yieldable(&self) -> bool {
unsafe { self.thread.is_yieldable() != 0 }
}
}