pub struct Context { /* private fields */ }Expand description
Cancellation, progress, threads and memory available to one heavy job.
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(
threads: usize,
budget: MemoryBudget,
progress: Arc<dyn ProgressSink>,
cancel: CancelToken,
) -> Self
pub fn new( threads: usize, budget: MemoryBudget, progress: Arc<dyn ProgressSink>, cancel: CancelToken, ) -> Self
Creates a context. A zero thread request is treated as one thread.
Sourcepub fn child_serial(&self) -> Context
pub fn child_serial(&self) -> Context
A one-thread context for work that runs inside one of this job’s items: it reserves from the same budget and stops with the same token, and reports no progress of its own.
Sourcepub fn serial() -> Self
pub fn serial() -> Self
Creates a one-thread context with an unlimited budget and no reporting.
Sourcepub fn cancel(&self) -> &CancelToken
pub fn cancel(&self) -> &CancelToken
Returns this job’s cancellation token.
Sourcepub fn budget(&self) -> &MemoryBudget
pub fn budget(&self) -> &MemoryBudget
Returns this job’s memory budget.
Sourcepub fn stage(&self, stage: &'static str, total: u64) -> StageProgress<'_>
pub fn stage(&self, stage: &'static str, total: u64) -> StageProgress<'_>
Starts a progress stage and immediately reports its initial state.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Context
impl !UnwindSafe for Context
impl Freeze for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more