use std::future::Future;
use qubit_function::{
Callable,
Runnable,
};
use super::{
RejectedExecution,
ShutdownReport,
};
pub trait ExecutorService: Send + Sync {
type Handle<R, E>
where
R: Send + 'static,
E: Send + 'static;
type Termination<'a>: Future<Output = ()> + Send + 'a
where
Self: 'a;
#[inline]
fn submit<T, E>(&self, task: T) -> Result<Self::Handle<(), E>, RejectedExecution>
where
T: Runnable<E> + Send + 'static,
E: Send + 'static,
{
let mut task = task;
self.submit_callable(move || task.run())
}
fn submit_callable<C, R, E>(&self, task: C) -> Result<Self::Handle<R, E>, RejectedExecution>
where
C: Callable<R, E> + Send + 'static,
R: Send + 'static,
E: Send + 'static;
fn shutdown(&self);
fn shutdown_now(&self) -> ShutdownReport;
fn is_shutdown(&self) -> bool;
fn is_terminated(&self) -> bool;
fn await_termination(&self) -> Self::Termination<'_>;
}