pub struct CacheIoWorker<Task, Output> { /* private fields */ }Expand description
Generic bounded background worker over opaque backend task and output types.
Implementations§
Source§impl<Task, Output> CacheIoWorker<Task, Output>
impl<Task, Output> CacheIoWorker<Task, Output>
Sourcepub fn new(
capacity: usize,
thread_name: impl Into<String>,
execute: fn(Task) -> Result<Output, String>,
discard: fn(Output),
) -> Result<Self, CacheIoWorkerError>
pub fn new( capacity: usize, thread_name: impl Into<String>, execute: fn(Task) -> Result<Output, String>, discard: fn(Output), ) -> Result<Self, CacheIoWorkerError>
Starts a bounded worker using statically dispatched task and cleanup functions.
Sourcepub fn with_nonblocking_drop(self) -> Self
pub fn with_nonblocking_drop(self) -> Self
Requests shutdown without joining from this handle’s destructor.
The worker owns in-flight tasks until they finish and discards queued tasks itself. Prepared submissions reject admission after shutdown.
Sourcepub fn prepare(
&self,
key: CacheIoOperationKey,
task: Task,
) -> Result<CacheIoSubmission<Task, Output>, CacheIoWorkerError>
pub fn prepare( &self, key: CacheIoOperationKey, task: Task, ) -> Result<CacheIoSubmission<Task, Output>, CacheIoWorkerError>
Prepares new work or joins an exact operation already owned by the worker.
Sourcepub fn retire(&self, ticket: &CacheIoTicket<Output>)
pub fn retire(&self, ticket: &CacheIoTicket<Output>)
Releases exact-key ownership after task resources are safe to drop.
Trait Implementations§
Source§impl<Task, Output> Debug for CacheIoWorker<Task, Output>
impl<Task, Output> Debug for CacheIoWorker<Task, Output>
Source§impl<Task, Output> Drop for CacheIoWorker<Task, Output>
impl<Task, Output> Drop for CacheIoWorker<Task, Output>
Auto Trait Implementations§
impl<Task, Output> !Freeze for CacheIoWorker<Task, Output>
impl<Task, Output> RefUnwindSafe for CacheIoWorker<Task, Output>where
Sender<CacheIoWorkerRequest<Task, Output>>: RefUnwindSafe,
Arc<CacheIoWorkerShared<Output>>: RefUnwindSafe,
impl<Task, Output> Send for CacheIoWorker<Task, Output>
impl<Task, Output> Sync for CacheIoWorker<Task, Output>
impl<Task, Output> Unpin for CacheIoWorker<Task, Output>
impl<Task, Output> UnsafeUnpin for CacheIoWorker<Task, Output>where
Sender<CacheIoWorkerRequest<Task, Output>>: UnsafeUnpin,
Arc<CacheIoWorkerShared<Output>>: UnsafeUnpin,
impl<Task, Output> UnwindSafe for CacheIoWorker<Task, Output>where
Sender<CacheIoWorkerRequest<Task, Output>>: UnwindSafe,
Arc<CacheIoWorkerShared<Output>>: UnwindSafe,
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