Skip to main content

ProgressTask

Struct ProgressTask 

Source
pub struct ProgressTask<R: Copy + 'static> { /* private fields */ }

Implementations§

Source§

impl<R: Copy + 'static> ProgressTask<R>

Source

pub fn create( base_path: impl AsRef<Path>, initial_result: R, ) -> Result<Self, ProgressTaskError>

Create a new ProgressTask at base_path. Allocates four MMF files; initialises progress=0, total=0, done=false, result= initial_result.

Source

pub fn open(base_path: impl AsRef<Path>) -> Result<Self, ProgressTaskError>

Open an existing ProgressTask at base_path. All four MMF files must exist.

Source

pub fn begin(&self, total: u64) -> ProgressReporter

Begin a new task run with the given total denominator. Resets progress=0, done=false, and publishes total. Returns a ProgressReporter for the work closure to advance.

Source

pub fn complete(&self, result: R)

Mark the task complete and publish the final result. Other processes observing is_done will see true after this call; read_result returns the published value.

Source

pub fn fraction_complete(&self) -> f64

Current fraction in [0.0, 1.0]. Returns 0.0 when total is 0 (no task has begun); clamped at 1.0 to avoid >100% display.

Source

pub fn current_progress(&self) -> u64

Current progress counter value.

Source

pub fn total(&self) -> u64

Total denominator for the current run (0 when no run is active).

Source

pub fn is_done(&self) -> bool

True when complete has been called for the current run.

Source

pub fn read_result(&self) -> Option<R>

Read the most-recently-published result. Returns None when is_done is false (a result MAY still be there from a prior completed run, but the current run is not yet finished).

Source

pub fn peek_result(&self) -> R

Read the result cell unconditionally. Useful for reading the initial value before any run, or for sampling a stale value.

Source

pub fn run<F>(&self, total: u64, work: F) -> R
where F: FnOnce(&ProgressReporter) -> R,

Run the work closure synchronously on the calling thread. Calls begin(total) to set up the reporter, runs the closure, publishes the result via complete, and returns the result.

Source

pub fn spawn<F>(self: &Arc<Self>, total: u64, work: F) -> JoinHandle<()>
where F: FnOnce(&ProgressReporter) -> R + Send + 'static, R: Send + Sync,

Spawn the work closure on a background thread. Returns a JoinHandle so the caller can wait if desired; the task’s completion is also visible via is_done.

Source

pub fn flush(&self) -> Result<(), ProgressTaskError>

Sync all four files to disk.

Source

pub fn flush_async(&self) -> Result<(), ProgressTaskError>

Non-blocking flush of all four files. Delegates to each inner primitive’s flush_async. Note: Windows is only partially async (sync to page cache, not to disk).

Trait Implementations§

Source§

impl<R: Copy + Send + Sync + 'static> AdaptiveInstance for ProgressTask<R>

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.

Auto Trait Implementations§

§

impl<R> !Freeze for ProgressTask<R>

§

impl<R> !UnwindSafe for ProgressTask<R>

§

impl<R> RefUnwindSafe for ProgressTask<R>
where R: RefUnwindSafe,

§

impl<R> Send for ProgressTask<R>
where R: Sync + Send,

§

impl<R> Sync for ProgressTask<R>
where R: Sync + Send,

§

impl<R> Unpin for ProgressTask<R>

§

impl<R> UnsafeUnpin for ProgressTask<R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.