Trait jlrs::extensions::multitask::call_async::CallAsync[][src]

pub trait CallAsync<'data>: Call<'data> {
    unsafe fn call_async<'frame, 'value, 'life0, 'async_trait, V>(
        self,
        frame: &'life0 mut AsyncGcFrame<'frame>,
        args: V
    ) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>>
    where
        V: AsMut<[Value<'value, 'data>]>,
        'frame: 'async_trait,
        'value: 'async_trait,
        V: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
unsafe fn schedule_async<'frame, 'value, V>(
        self,
        frame: &mut AsyncGcFrame<'frame>,
        args: V
    ) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>>
    where
        V: AsMut<[Value<'value, 'data>]>
;
unsafe fn call_async_local<'frame, 'value, 'life0, 'async_trait, V>(
        self,
        frame: &'life0 mut AsyncGcFrame<'frame>,
        args: V
    ) -> Pin<Box<dyn Future<Output = JlrsResult<JuliaResult<'frame, 'data>>> + 'async_trait>>
    where
        V: AsMut<[Value<'value, 'data>]>,
        'frame: 'async_trait,
        'value: 'async_trait,
        V: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
unsafe fn schedule_async_local<'frame, 'value, V>(
        self,
        frame: &mut AsyncGcFrame<'frame>,
        args: V
    ) -> JlrsResult<JuliaResult<'frame, 'data, Task<'frame>>>
    where
        V: AsMut<[Value<'value, 'data>]>
; }
Expand description

This trait provides async methods to create and schedule Tasks that resolve when the Task has completed. Non-async methods are also provided which only schedule the Task, those methods should only be used from GeneratorTask::init.

Required methods

Call a function on another thread with the given arguments. This method uses Base.Threads.@spawn to call the given function on another thread but return immediately. While awaiting the result the async runtime can work on other tasks, the current task resumes after the function call on the other thread completes.

Safety: this method lets you call arbitrary Julia functions which can’t be checked for correctness. If the second lifetime of an argument is not 'static, it must never be assigned to a global.

Does the same thing as CallAsync::call_async, but the task is returned rather than an awaitable Future. This method should only be called in GeneratorTask::init, otherwise it’s not guaranteed this task can progress.

Safety: this method lets you call arbitrary Julia functions which can’t be checked for correctness. If the second lifetime of an argument is not 'static, it must never be assigned to a global.

Call a function with the given arguments in an @async block. Like call_async, the function is not called on the main thread, but on a separate thread that handles all tasks created by this method. This method should only be used with functions that do very little computational work but mostly spend their time waiting on IO.

Safety: this method lets you call arbitrary Julia functions which can’t be checked for correctness. If the second lifetime of an argument is not 'static, it must never be assigned to a global.

Does the same thing as CallAsync::call_async_local, but the task is returned rather than an awaitable Future. This method should only be called in GeneratorTask::init, otherwise it’s not guaranteed this task can progress.

Safety: this method lets you call arbitrary Julia functions which can’t be checked for correctness. If the second lifetime of an argument is not 'static, it must never be assigned to a global.

Implementors