Trait fibers::Executor
[−]
[src]
pub trait Executor: Sized { type Handle: Spawn + Clone + Send + 'static; fn handle(&self) -> Self::Handle; fn run_once(&mut self) -> Result<()>; fn spawn<F>(&self, future: F) where F: Future<Item=(), Error=()> + Send + 'static { ... } fn spawn_fn<F, T>(&self, f: F) where F: FnOnce() -> T + Send + 'static,
T: IntoFuture<Item=(), Error=()> + Send + 'static,
T::Future: Send { ... } fn spawn_monitor<F, T, E>(&self, f: F) -> Monitor<T, E> where F: Future<Item=T, Error=E> + Send + 'static,
T: Send + 'static,
E: Send + 'static { ... } fn run_fiber<T, E>(&mut self,
monitor: Monitor<T, E>)
-> Result<Result<T, MonitorError<E>>> { ... } fn run(self) -> Result<()> { ... } }
The Executor
trait allows for spawning and executing fibers.
Associated Types
Required Methods
fn handle(&self) -> Self::Handle
Returns the handle of the executor.
fn run_once(&mut self) -> Result<()>
Runs one one unit of works.
Provided Methods
fn spawn<F>(&self, future: F) where F: Future<Item=(), Error=()> + Send + 'static
Spawns a fiber which will execute given future.
fn spawn_fn<F, T>(&self, f: F) where F: FnOnce() -> T + Send + 'static,
T: IntoFuture<Item=(), Error=()> + Send + 'static,
T::Future: Send
T: IntoFuture<Item=(), Error=()> + Send + 'static,
T::Future: Send
Equivalent to self.spawn(futures::lazy(|| f()))
.
fn spawn_monitor<F, T, E>(&self, f: F) -> Monitor<T, E> where F: Future<Item=T, Error=E> + Send + 'static,
T: Send + 'static,
E: Send + 'static
T: Send + 'static,
E: Send + 'static
Spawns a fiber and returns a future to monitor it's execution result.
fn run_fiber<T, E>(&mut self,
monitor: Monitor<T, E>)
-> Result<Result<T, MonitorError<E>>>
monitor: Monitor<T, E>)
-> Result<Result<T, MonitorError<E>>>
Runs until the monitored fiber exits.
fn run(self) -> Result<()>
Runs infinitely until an error happens.
Implementors
impl Executor for InPlaceExecutor
impl Executor for ThreadPoolExecutor