pub struct Executor { /* private fields */ }Expand description
Object which holds the state of the work queue and allows queueing tasks to run on the thread pool.
Implementations§
Source§impl Executor
impl Executor
Sourcepub fn new(concurrency: usize) -> Executor
pub fn new(concurrency: usize) -> Executor
Instantiates a new work queue and creates the threads to service it.
The threads will exit when the Executor goes out of scope (not yet
implemented). In the future, we may have process-level coordination
to allow different Executors to share a thread pool, and use per-job
concurrency limits.
Sourcepub fn exec<TASK, RV>(&self, estimate: usize, task: TASK) -> Promise<RV>
pub fn exec<TASK, RV>(&self, estimate: usize, task: TASK) -> Promise<RV>
Queue a job on this work queue.
The estimate is meaningless in isolation but jobs with a higher estimate will be dispatched first, so it should be comparable among jobs that could simultaneously be in the work queue.
Returns a Promise that can be used to wait for completion of the
queued work. If the provided task panics, the error will be stored and
rethrown when the promise is awaited.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Executor
impl RefUnwindSafe for Executor
impl Send for Executor
impl Sync for Executor
impl Unpin for Executor
impl UnwindSafe for Executor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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