pub trait LuaSchedulerExt<'lua> {
    // Required methods
    fn set_exit_code(&self, code: ExitCode);
    fn push_thread_front(
        &'lua self,
        thread: impl IntoLuaThread<'lua>,
        args: impl IntoLuaMulti<'lua>
    ) -> LuaResult<ThreadId>;
    fn push_thread_back(
        &'lua self,
        thread: impl IntoLuaThread<'lua>,
        args: impl IntoLuaMulti<'lua>
    ) -> LuaResult<ThreadId>;
    fn track_thread(&'lua self, id: ThreadId);
    fn get_thread_result(
        &'lua self,
        id: ThreadId
    ) -> Option<LuaResult<LuaMultiValue<'lua>>>;
    fn wait_for_thread(&'lua 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: ExitCode)

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( &'lua self, thread: impl IntoLuaThread<'lua>, args: impl IntoLuaMulti<'lua> ) -> 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( &'lua self, thread: impl IntoLuaThread<'lua>, args: impl IntoLuaMulti<'lua> ) -> 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(&'lua 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( &'lua self, id: ThreadId ) -> Option<LuaResult<LuaMultiValue<'lua>>>

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(&'lua 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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'lua> LuaSchedulerExt<'lua> for Lua

source§

fn set_exit_code(&self, code: ExitCode)

source§

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

source§

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

source§

fn track_thread(&'lua self, id: ThreadId)

source§

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

source§

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

Implementors§