[][src]Trait apis::process::Process

pub trait Process<CTX, RES> where
    CTX: Context,
    RES: Presult<CTX, Self>,
    Self: TryFrom<CTX::GPROC> + Into<CTX::GPROC>, 
{ fn new(inner: Inner<CTX>) -> Self;
fn inner_ref(&self) -> &Inner<CTX>;
fn inner_mut(&mut self) -> &mut Inner<CTX>;
fn result_ref(&self) -> &RES;
fn result_mut(&mut self) -> &mut RES;
fn global_result(&mut self) -> CTX::GPRES;
fn extract_result(
        session_results: &mut VecMap<CTX::GPRES>
    ) -> Result<RES, String>;
fn handle_message(&mut self, message: CTX::GMSG) -> ControlFlow;
fn update(&mut self) -> ControlFlow; fn initialize(&mut self) { ... }
fn terminate(&mut self) { ... }
fn id(&self) -> &CTX::PID
    where
        CTX: 'static
, { ... }
fn kind(&self) -> &Kind
    where
        CTX: 'static
, { ... }
fn state_id(&self) -> StateId { ... }
fn def(&self) -> &Def<CTX> { ... }
fn sourcepoints(&self) -> &VecMap<Box<dyn Sourcepoint<CTX>>> { ... }
fn sourcepoints_mut(&mut self) -> &mut VecMap<Box<dyn Sourcepoint<CTX>>> { ... }
fn endpoints(&self) -> Ref<'_, Option<VecMap<Box<dyn Endpoint<CTX>>>>> { ... }
fn endpoints_mut(
        &mut self
    ) -> RefMut<'_, Option<VecMap<Box<dyn Endpoint<CTX>>>>> { ... }
fn take_endpoints(&self) -> VecMap<Box<dyn Endpoint<CTX>>> { ... }
fn put_endpoints(&self, endpoints: VecMap<Box<dyn Endpoint<CTX>>>) { ... }
fn send<M: Message<CTX>>(
        &self,
        channel_id: CTX::CID,
        message: M
    ) -> Result<(), SendError<CTX::GMSG>>
    where
        CTX: 'static
, { ... }
fn send_to<M: Message<CTX>>(
        &self,
        channel_id: CTX::CID,
        recipient: CTX::PID,
        message: M
    ) -> Result<(), SendError<CTX::GMSG>>
    where
        CTX: 'static
, { ... }
fn run(&mut self)
    where
        Self: Sized + 'static,
        CTX: 'static
, { ... }
fn run_continue(self) -> Option<()>
    where
        Self: Sized + 'static,
        CTX: 'static
, { ... }
fn run_asynchronous(&mut self)
    where
        Self: Sized,
        CTX: 'static
, { ... }
fn run_isochronous(&mut self)
    where
        Self: Sized,
        CTX: 'static
, { ... }
fn run_mesochronous(&mut self)
    where
        Self: Sized,
        CTX: 'static
, { ... }
fn run_anisochronous(&mut self)
    where
        Self: Sized,
        CTX: 'static
, { ... } }

Main process trait.

Required methods

fn new(inner: Inner<CTX>) -> Self

fn inner_ref(&self) -> &Inner<CTX>

fn inner_mut(&mut self) -> &mut Inner<CTX>

fn result_ref(&self) -> &RES

fn result_mut(&mut self) -> &mut RES

fn global_result(&mut self) -> CTX::GPRES

fn extract_result(
    session_results: &mut VecMap<CTX::GPRES>
) -> Result<RES, String>

fn handle_message(&mut self, message: CTX::GMSG) -> ControlFlow

fn update(&mut self) -> ControlFlow

Loading content...

Provided methods

fn initialize(&mut self)

Does nothing by default, may be overridden.

fn terminate(&mut self)

Does nothing by default, may be overridden.

fn id(&self) -> &CTX::PID where
    CTX: 'static, 

fn kind(&self) -> &Kind where
    CTX: 'static, 

fn state_id(&self) -> StateId

fn def(&self) -> &Def<CTX>

fn sourcepoints(&self) -> &VecMap<Box<dyn Sourcepoint<CTX>>>

fn sourcepoints_mut(&mut self) -> &mut VecMap<Box<dyn Sourcepoint<CTX>>>

fn endpoints(&self) -> Ref<'_, Option<VecMap<Box<dyn Endpoint<CTX>>>>>

This method returns a Ref <Option <...>> because during the run loop the endpoints will be unavailable as they are being iterated over. Endpoints are automatically waited on or polled in the appropriate run_* function. Endpoints will be present for the calls to terminate or initialize, either before or after the run loop, respectively.

fn endpoints_mut(
    &mut self
) -> RefMut<'_, Option<VecMap<Box<dyn Endpoint<CTX>>>>>

This method returns a Ref <Option <...>> because during the run loop the endpoints will be unavailable as they are being iterated over. Endpoints are automatically waited on or polled in the appropriate run_* function. Endpoints will be present for the calls to terminate or initialize, either before or after the run loop, respectively.

fn take_endpoints(&self) -> VecMap<Box<dyn Endpoint<CTX>>>

This method is used within the process run_* methods to get the endpoints without borrowing the process. Endpoints will then be replaced with None and unavailable within the run loop.

Errors

Taking twice is a fatal error.

fn put_endpoints(&self, endpoints: VecMap<Box<dyn Endpoint<CTX>>>)

Errors

Error if current endpoints are not None.

fn send<M: Message<CTX>>(
    &self,
    channel_id: CTX::CID,
    message: M
) -> Result<(), SendError<CTX::GMSG>> where
    CTX: 'static, 

fn send_to<M: Message<CTX>>(
    &self,
    channel_id: CTX::CID,
    recipient: CTX::PID,
    message: M
) -> Result<(), SendError<CTX::GMSG>> where
    CTX: 'static, 

fn run(&mut self) where
    Self: Sized + 'static,
    CTX: 'static, 

Run a process to completion and send the result on the result channel.

fn run_continue(self) -> Option<()> where
    Self: Sized + 'static,
    CTX: 'static, 

Run a process to completion, send the result to the session, and proceed with the continuation received from the session.

fn run_asynchronous(&mut self) where
    Self: Sized,
    CTX: 'static, 

Asynchronous run loop waits for messages on the single endpoint held by this process and calls the process update method for every $n >= 1$ messages as specified by the process kind.

fn run_isochronous(&mut self) where
    Self: Sized,
    CTX: 'static, 

This function implements a fixed-timestep update loop.

Time is checked immediately after update and the thread is put to sleep for the time remaining until the next update, plus 1 ms since the thread usually wakes up slightly before the set time. In practice this means that the update time lags behind the target time by about 1ms or so, but the time between updates is consistent. If the thread does somehow wake up too early, then no update will be done and the thread will sleep or else loop immediately depending on the result of a second time query.

After an update, if the next (absolute) tick time has already passed, then the thread will not sleep and instead will loop immediately. Note that the tick time is measured on an absolute clock, allowing the thread to "catch up" in case of a long update by processing the "backlog" of ticks as fast as possible.

fn run_mesochronous(&mut self) where
    Self: Sized,
    CTX: 'static, 

This function implements a rate-limited update loop.

Time is checked immediately after update and the thread is put to sleep for the time remaining until the next update, plus 1 ms since the thread usually wakes up slightly before the set time. In practice this means that the update time lags behind the target time by about 1ms or so, but the time between updates is consistent. If the thread does somehow wake up too early, then no update will be done and the thread will sleep, or else loop immediately depending on the result of a second time query.

After a tick, if the next tick time has already passed, then the thread will not sleep and instead will loop immediately.

fn run_anisochronous(&mut self) where
    Self: Sized,
    CTX: 'static, 

An un-timed run loop that polls for messages.

Loading content...

Implementors

Loading content...