Struct ComputeTask

Source
pub struct ComputeTask<R> { /* private fields */ }
Expand description

A task that can terminate and return its return value. Implemented using an atomically shared mutex.

Sample usage:

use freertos_rs::patterns::compute_task::*;
let task = Task::new().compute(|| {
	CurrentTask::delay(Duration::ms(100));
	42
}).unwrap();

let result = task.into_result(Duration::ms(1000)).unwrap();

Implementations§

Source§

impl<R: Debug> ComputeTask<R>

Source

pub fn get_task(&self) -> &Task

Get the handle of the task that computes the result.

Source

pub fn wait_for_result<D: DurationTicks>( &mut self, max_wait: D, ) -> Result<(), FreeRtosError>

Wait until the task computes its result. Otherwise, returns a timeout.

Source

pub fn into_result<D: DurationTicks>( self, max_wait: D, ) -> Result<R, FreeRtosError>

Consume the task and unwrap the computed return value.

Auto Trait Implementations§

§

impl<R> Freeze for ComputeTask<R>

§

impl<R> !RefUnwindSafe for ComputeTask<R>

§

impl<R> Send for ComputeTask<R>
where R: Sync + Send,

§

impl<R> !Sync for ComputeTask<R>

§

impl<R> Unpin for ComputeTask<R>

§

impl<R> !UnwindSafe for ComputeTask<R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.