zephyr::work::futures

Struct WorkBuilder

Source
pub struct WorkBuilder { /* private fields */ }
Expand description

Build a combiner for Future and a Zephyr work queue. This encapsulates the idea of starting a new thread of work, and is the basis of both the main run for work queues, as well as any calls to spawn that happen within the Future world.

Implementations§

Source§

impl WorkBuilder

Source

pub fn new() -> Self

Construct a new builder for work.

The builder will default to running on the system workqueue.

Source

pub fn set_worker(&mut self, worker: &WorkQueue) -> &mut Self

Set the work queue for this worker to run on.

By default, A Worker will run on the system work-queue.

Source

pub fn set_name(&mut self, name: &'static CStr) -> &mut Self

Set a name for this worker, for debugging.

Source

pub fn start<F: Future + Send>(&self, future: F) -> JoinHandle<F>

Start this working, consuming the given Future to do the work.

The work queue is in a pinned Arc to meet requirements of how Futures are used. The Arc maintains lifetime while the worker is running. See notes below for issues of lifetimes and canceled work.

Source

pub fn start_local<F: Future>(&self, future: F) -> JoinHandle<F>

Start this work, locally running on the current worker thread.

This is the same as start, but the work will always be started on the current work queue thread. This relaxes the Send requirement, as the data will always be contained in a single thread.

§Panics

If called from other than a Future running on a work queue, will panic. The System work queue is not yet supported.

Auto Trait Implementations§

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.