pub struct PoolJob { /* private fields */ }Expand description
Type-erased pool job with a cancellation path for queued work.
PoolJob is a low-level extension point for building custom services on
top of super::thread_pool::ThreadPool. The pool calls the run callback after a worker takes
the job, or the cancel callback if the job is still queued during immediate
shutdown.
Implementations§
Source§impl PoolJob
impl PoolJob
Sourcepub fn new(
run: Box<dyn FnOnce() + Send + 'static>,
cancel: Box<dyn FnOnce() + Send + 'static>,
) -> Self
pub fn new( run: Box<dyn FnOnce() + Send + 'static>, cancel: Box<dyn FnOnce() + Send + 'static>, ) -> Self
Creates a pool job from run and cancel callbacks.
§Parameters
run- Callback executed once a worker starts this job.cancel- Callback executed if this job is cancelled while queued.
§Returns
A type-erased job accepted by super::thread_pool::ThreadPool::submit_job.
Sourcepub fn from_task<C, R, E>(task: C, completion: TaskCompletion<R, E>) -> Self
pub fn from_task<C, R, E>(task: C, completion: TaskCompletion<R, E>) -> Self
Creates a pool job from a typed callable task and completion endpoint.
§Parameters
task- Callable task to execute when a worker starts this job.completion- Completion endpoint used to publish the typed result or cancellation.
§Returns
A type-erased job that runs the task on worker start and cancels the completion endpoint if the job is abandoned while queued.
Auto Trait Implementations§
impl Freeze for PoolJob
impl !RefUnwindSafe for PoolJob
impl Send for PoolJob
impl !Sync for PoolJob
impl Unpin for PoolJob
impl UnsafeUnpin for PoolJob
impl !UnwindSafe for PoolJob
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
Mutably borrows from an owned value. Read more