pub struct OffloadManager { /* private fields */ }Expand description
Manager for offloading tasks to background execution.
Supports task deduplication, timeout policies, and metrics collection.
Implementations§
Source§impl OffloadManager
impl OffloadManager
Sourcepub fn new(config: OffloadConfig) -> Self
pub fn new(config: OffloadConfig) -> Self
Create a new OffloadManager with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a new OffloadManager with default configuration.
Sourcepub fn spawn<F>(&self, kind: impl Into<SmolStr>, task: F) -> OffloadKey
pub fn spawn<F>(&self, kind: impl Into<SmolStr>, task: F) -> OffloadKey
Sourcepub fn spawn_with_key<K, F>(&self, key: K, task: F) -> bool
pub fn spawn_with_key<K, F>(&self, key: K, task: F) -> bool
Spawn a task with a specific key.
If a task with the same key is already in flight and deduplication is enabled, the new task will be skipped.
Returns true if the task was spawned, false if it was deduplicated.
Sourcepub fn active_task_count(&self) -> usize
pub fn active_task_count(&self) -> usize
Get the number of currently active tasks.
Sourcepub fn total_task_count(&self) -> usize
pub fn total_task_count(&self) -> usize
Get the total number of tracked tasks (including finished).
Sourcepub fn cleanup_finished(&self)
pub fn cleanup_finished(&self)
Clean up finished task handles.
Sourcepub fn cancel_all(&self)
pub fn cancel_all(&self)
Cancel all running tasks.
Sourcepub fn cancel(&self, key: &OffloadKey) -> bool
pub fn cancel(&self, key: &OffloadKey) -> bool
Cancel a specific task by key.
Sourcepub fn is_in_flight(&self, key: &OffloadKey) -> bool
pub fn is_in_flight(&self, key: &OffloadKey) -> bool
Check if a task with the given key is in flight.
Sourcepub async fn wait_all(&self)
pub async fn wait_all(&self)
Wait for all currently tracked tasks to complete.
This polls active tasks until all are finished, with a small yield between checks to avoid busy-waiting.
Sourcepub async fn wait_all_timeout(&self, timeout: Duration) -> bool
pub async fn wait_all_timeout(&self, timeout: Duration) -> bool
Wait for all tasks with a timeout.
Returns true if all tasks completed within the timeout,
false if the timeout was reached.
Trait Implementations§
Source§impl Clone for OffloadManager
impl Clone for OffloadManager
Source§fn clone(&self) -> OffloadManager
fn clone(&self) -> OffloadManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OffloadManager
impl Debug for OffloadManager
Source§impl Default for OffloadManager
impl Default for OffloadManager
Auto Trait Implementations§
impl Freeze for OffloadManager
impl !RefUnwindSafe for OffloadManager
impl Send for OffloadManager
impl Sync for OffloadManager
impl Unpin for OffloadManager
impl !UnwindSafe for OffloadManager
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.