pub trait Task<R: Send>: Send {
// Required methods
fn run(self) -> R;
fn into_fn(self) -> Option<Box<dyn FnOnce() -> R + Send + 'static>>;
fn is_fn(&self) -> bool;
}Expand description
Trait to implement for all items that may be executed by the ThreadPool.
Required Methods§
Sourcefn into_fn(self) -> Option<Box<dyn FnOnce() -> R + Send + 'static>>
fn into_fn(self) -> Option<Box<dyn FnOnce() -> R + Send + 'static>>
Transform this Task into a heap allocated FnOnce if possible.
Used by ThreadPool::execute to turn this Task into a Job
directly without having to create an additional Job that calls this Task.
Sourcefn is_fn(&self) -> bool
fn is_fn(&self) -> bool
Return true if calling Task::into_fn on this Task returns Some.
Implementations on Foreign Types§
Source§impl Task<()> for Arc<AsyncTask>
Implement the Task trait for AsyncTask in order to make it executable for the pool by
creating a waker and polling the future.
impl Task<()> for Arc<AsyncTask>
Implement the Task trait for AsyncTask in order to make it executable for the pool by
creating a waker and polling the future.