use super::id_and_context::TaskContext;
pub trait Task: Send + 'static {
type Output: Send + 'static;
fn execute(self) -> Self::Output;
fn context(&self) -> &TaskContext;
fn is_stealable(&self) -> bool {
true
}
fn estimated_cost(&self) -> u32 {
1
}
}
#[cfg(feature = "std")]
impl<T> Task for Box<T>
where
T: Task,
{
type Output = T::Output;
fn execute(self) -> Self::Output {
(*self).execute()
}
fn context(&self) -> &TaskContext {
(**self).context()
}
fn is_stealable(&self) -> bool {
(**self).is_stealable()
}
fn estimated_cost(&self) -> u32 {
(**self).estimated_cost()
}
}