Trait jlrs::extensions::multitask::async_task::PersistentTask[][src]

pub trait PersistentTask: 'static + Send + Sync {
    type State: 'static;
    type Input: 'static + Send + Sync;
    type Output: 'static + Send + Sync;

    const CHANNEL_CAPACITY: usize;
    const REGISTER_SLOTS: usize;
    const INIT_SLOTS: usize;
    const RUN_SLOTS: usize;

    fn init<'inner, 'async_trait>(
        &'inner mut self,
        global: Global<'static>,
        frame: &'inner mut AsyncGcFrame<'static>
    ) -> Pin<Box<dyn Future<Output = JlrsResult<Self::State>> + 'async_trait>>
    where
        'inner: 'async_trait,
        Self: 'async_trait
;
fn run<'inner, 'frame, 'async_trait>(
        &'inner mut self,
        global: Global<'frame>,
        frame: &'inner mut AsyncGcFrame<'frame>,
        state: &'inner mut Self::State,
        input: Self::Input
    ) -> Pin<Box<dyn Future<Output = JlrsResult<Self::Output>> + 'async_trait>>
    where
        'inner: 'async_trait,
        'frame: 'async_trait,
        Self: 'async_trait
; fn register<'frame, 'life0, 'async_trait>(
        _global: Global<'frame>,
        _frame: &'life0 mut AsyncGcFrame<'frame>
    ) -> Pin<Box<dyn Future<Output = JlrsResult<()>> + 'async_trait>>
    where
        'frame: 'async_trait,
        'life0: 'async_trait
, { ... }
fn exit<'inner, 'async_trait>(
        &'inner mut self,
        _global: Global<'static>,
        _frame: &'inner mut AsyncGcFrame<'static>,
        _state: &'inner mut Self::State
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
    where
        'inner: 'async_trait,
        Self: 'async_trait
, { ... } }
Expand description

A task that can be called multiple times. In order to schedule the task you must use AsyncJulia::persistent or AsyncJulia::try_persistent.

Associated Types

The type of the result which is returned if init completes successfully. This data is provided to every call of run. Because init takes a frame with the 'static lifetime, this type can contain Julia data.

The type of the data that must be provided when calling this persistent through its handle.

The type of the result which is returned if run completes successfully.

Associated Constants

The capacity of the channel the PersistentHandle uses to communicate with this persistent.

If it’s set to 0, the channel is unbounded.

The number of slots preallocated for the AsyncGcFrame provided to register.

The number of slots preallocated for the AsyncGcFrame provided to init.

The number of slots preallocated for the AsyncGcFrame provided to run.

Required methods

Initialize the task. You can interact with Julia inside this method, the frame is not dropped until the task itself is dropped. This means that State can contain arbitrary Julia data rooted in this frame. This data is provided to every call to run.

Run the task. This method takes a Global and a mutable reference to an AsyncGcFrame, which lets you interact with Julia. It’s also provided with a mutable reference to its state and the input provided by the caller. While the state is mutable, it’s not possible to allocate a new Julia value in run and assign it to the state because the frame doesn’t live long enough.

Provided methods

Register this persistent. Note that this method is not called automatically, but only if AsyncJulia::register_persistent or AsyncJulia::try_register_persistent is used. This method can be implemented to take care of everything required to execute the task successfully, like loading packages.

Implementors