Skip to main content

LuaSchedulerExt

Trait LuaSchedulerExt 

Source
pub trait LuaSchedulerExt {
    // Required methods
    fn set_exit_code(&self, code: u8);
    fn push_thread_front(
        &self,
        thread: impl IntoLuaThread,
        args: impl IntoLuaMulti,
    ) -> LuaResult<ThreadId>;
    fn push_thread_back(
        &self,
        thread: impl IntoLuaThread,
        args: impl IntoLuaMulti,
    ) -> LuaResult<ThreadId>;
    fn track_thread(&self, id: ThreadId);
    fn get_thread_result(
        &self,
        id: ThreadId,
    ) -> Option<LuaResult<LuaMultiValue>>;
    fn wait_for_thread(&self, id: ThreadId) -> impl Future<Output = ()>;
}
Expand description

Trait for interacting with the current Scheduler.

Provides extra methods on the Lua struct for:

  • Setting the exit code and forcibly stopping the scheduler
  • Pushing (spawning) and deferring (pushing to the back) lua threads
  • Tracking and getting the result of lua threads

Required Methods§

Source

fn set_exit_code(&self, code: u8)

Sets the exit code of the current scheduler.

See Scheduler::set_exit_code for more information.

§Panics

Panics if called outside of a running Scheduler.

Source

fn push_thread_front( &self, thread: impl IntoLuaThread, args: impl IntoLuaMulti, ) -> LuaResult<ThreadId>

Pushes (spawns) a lua thread to the front of the current scheduler.

See Scheduler::push_thread_front for more information.

§Panics

Panics if called outside of a running Scheduler.

Source

fn push_thread_back( &self, thread: impl IntoLuaThread, args: impl IntoLuaMulti, ) -> LuaResult<ThreadId>

Pushes (defers) a lua thread to the back of the current scheduler.

See Scheduler::push_thread_back for more information.

§Panics

Panics if called outside of a running Scheduler.

Source

fn track_thread(&self, id: ThreadId)

Registers the given thread to be tracked within the current scheduler.

Must be called before waiting for a thread to complete or getting its result.

Source

fn get_thread_result(&self, id: ThreadId) -> Option<LuaResult<LuaMultiValue>>

Gets the result of the given thread.

See Scheduler::get_thread_result for more information.

§Panics

Panics if called outside of a running Scheduler.

Source

fn wait_for_thread(&self, id: ThreadId) -> impl Future<Output = ()>

Waits for the given thread to complete.

See Scheduler::wait_for_thread for more information.

§Panics

Panics if called outside of a running Scheduler.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl LuaSchedulerExt for Lua

Implementors§