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
impl WorkBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new builder for work.
The builder will default to running on the system workqueue.
Sourcepub fn set_worker(&mut self, worker: &WorkQueue) -> &mut Self
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.
Sourcepub fn set_name(&mut self, name: &'static CStr) -> &mut Self
pub fn set_name(&mut self, name: &'static CStr) -> &mut Self
Set a name for this worker, for debugging.
Sourcepub fn start<F: Future + Send>(&self, future: F) -> JoinHandle<F>
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.
Sourcepub fn start_local<F: Future>(&self, future: F) -> JoinHandle<F>
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.