pub struct CuAsyncTask<T, O>where
T: for<'m> CuTask<Output<'m> = CuStampedData<O, CuMsgMetadata>> + Send + 'static,
O: CuMsgPayload + Send + 'static,{ /* private fields */ }
Implementations§
Source§impl<T, O> CuAsyncTask<T, O>where
T: for<'m> CuTask<Output<'m> = CuStampedData<O, CuMsgMetadata>> + Send + 'static,
O: CuMsgPayload + Send + 'static,
impl<T, O> CuAsyncTask<T, O>where
T: for<'m> CuTask<Output<'m> = CuStampedData<O, CuMsgMetadata>> + Send + 'static,
O: CuMsgPayload + Send + 'static,
pub fn new( config: Option<&ComponentConfig>, tp: Arc<ThreadPool>, ) -> Result<CuAsyncTask<T, O>, CuError>
Trait Implementations§
Source§impl<T, I, O> CuTask for CuAsyncTask<T, O>where
T: for<'i, 'o> CuTask<Input<'i> = CuStampedData<I, CuMsgMetadata>, Output<'o> = CuStampedData<O, CuMsgMetadata>> + Send + 'static,
I: CuMsgPayload + Send + Sync + 'static,
O: CuMsgPayload + Send + 'static,
impl<T, I, O> CuTask for CuAsyncTask<T, O>where
T: for<'i, 'o> CuTask<Input<'i> = CuStampedData<I, CuMsgMetadata>, Output<'o> = CuStampedData<O, CuMsgMetadata>> + Send + 'static,
I: CuMsgPayload + Send + Sync + 'static,
O: CuMsgPayload + Send + 'static,
type Input<'m> = <T as CuTask>::Input<'m>
type Output<'m> = <T as CuTask>::Output<'m>
Source§fn new(_config: Option<&ComponentConfig>) -> Result<CuAsyncTask<T, O>, CuError>where
CuAsyncTask<T, O>: Sized,
fn new(_config: Option<&ComponentConfig>) -> Result<CuAsyncTask<T, O>, CuError>where
CuAsyncTask<T, O>: Sized,
Here you need to initialize everything your task will need for the duration of its lifetime.
The config allows you to access the configuration of the task.
Source§fn process<'i, 'o>(
&mut self,
clock: &RobotClock,
input: &<CuAsyncTask<T, O> as CuTask>::Input<'i>,
real_output: &mut <CuAsyncTask<T, O> as CuTask>::Output<'o>,
) -> Result<(), CuError>
fn process<'i, 'o>( &mut self, clock: &RobotClock, input: &<CuAsyncTask<T, O> as CuTask>::Input<'i>, real_output: &mut <CuAsyncTask<T, O> as CuTask>::Output<'o>, ) -> Result<(), CuError>
Process is the most critical execution of the task.
The goal will be to produce the output message as soon as possible.
Use preprocess to prepare the task to make this method as short as possible.
Source§fn start(&mut self, _clock: &RobotClock) -> Result<(), CuError>
fn start(&mut self, _clock: &RobotClock) -> Result<(), CuError>
Start is called between the creation of the task and the first call to pre/process.
Source§fn preprocess(&mut self, _clock: &RobotClock) -> Result<(), CuError>
fn preprocess(&mut self, _clock: &RobotClock) -> Result<(), CuError>
This is a method called by the runtime before “process”. This is a kind of best effort,
as soon as possible call to give a chance for the task to do some work before to prepare
to make “process” as short as possible.
Source§fn postprocess(&mut self, _clock: &RobotClock) -> Result<(), CuError>
fn postprocess(&mut self, _clock: &RobotClock) -> Result<(), CuError>
This is a method called by the runtime after “process”. It is best effort a chance for
the task to update some state after process is out of the way.
It can be use for example to maintain statistics etc. that are not time-critical for the robot.
Source§impl<T, O> Freezable for CuAsyncTask<T, O>where
T: for<'m> CuTask<Output<'m> = CuStampedData<O, CuMsgMetadata>> + Send + 'static,
O: CuMsgPayload + Send + 'static,
impl<T, O> Freezable for CuAsyncTask<T, O>where
T: for<'m> CuTask<Output<'m> = CuStampedData<O, CuMsgMetadata>> + Send + 'static,
O: CuMsgPayload + Send + 'static,
Source§fn freeze<E>(&self, encoder: &mut E) -> Result<(), EncodeError>where
E: Encoder,
fn freeze<E>(&self, encoder: &mut E) -> Result<(), EncodeError>where
E: Encoder,
This method is called by the framework when it wants to save the task state.
The default implementation is to encode nothing (stateless).
If you have a state, you need to implement this method.
Source§fn thaw<D>(&mut self, _decoder: &mut D) -> Result<(), DecodeError>where
D: Decoder,
fn thaw<D>(&mut self, _decoder: &mut D) -> Result<(), DecodeError>where
D: Decoder,
This method is called by the framework when it wants to restore the task to a specific state.
Here it is similar to Decode but the framework will give you a new instance of the task (the new method will be called)
Auto Trait Implementations§
impl<T, O> Freeze for CuAsyncTask<T, O>
impl<T, O> !RefUnwindSafe for CuAsyncTask<T, O>
impl<T, O> Send for CuAsyncTask<T, O>
impl<T, O> Sync for CuAsyncTask<T, O>
impl<T, O> Unpin for CuAsyncTask<T, O>
impl<T, O> !UnwindSafe for CuAsyncTask<T, O>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more