pub struct ProgressReporter { /* private fields */ }Expand description
A throttled sink for pipeline progress.
Pass Some(&reporter) to a *_with_progress entry point; the reporter may
be shared across threads and outlive the call.
§Example
use manifold_rust::progress::ProgressReporter;
use manifold_rust::manifold::Manifold;
use manifold_rust::linalg::Vec3;
use manifold_rust::types::{BooleanEngine, OpType};
use std::sync::{Arc, Mutex};
let seen = Arc::new(Mutex::new(Vec::new()));
let sink = Arc::clone(&seen);
let reporter = ProgressReporter::new(move |phase, fraction| {
sink.lock().unwrap().push((phase.name(), fraction));
});
let a = Manifold::cube(Vec3::splat(1.0), true);
let b = Manifold::sphere(0.6, 16);
let out = a.boolean_with_engine_and_progress(
&b, OpType::Add, BooleanEngine::Robust, None, Some(&reporter),
);
assert!(out.volume() > 0.0);
assert!(!seen.lock().unwrap().is_empty());Implementations§
Source§impl ProgressReporter
impl ProgressReporter
pub fn new<F>(callback: F) -> Self
Sourcepub fn begin_phase(&self, phase: Phase, total: u64)
pub fn begin_phase(&self, phase: Phase, total: u64)
Enter phase, expecting total work items (0 = no total known, which
reports as an indeterminate phase). Always emits a callback, so a phase
transition is never throttled away.
Sourcepub fn advance(&self, n: u64)
pub fn advance(&self, n: u64)
Record n completed work items in the current phase, emitting a
callback only when the throttle threshold is crossed.
Safe to call from several threads at once; the counter is atomic and the callback is serialized. Under contention two threads can both cross the threshold and both report, which is harmless — this is a UI hint, not a ledger.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ProgressReporter
impl RefUnwindSafe for ProgressReporter
impl Send for ProgressReporter
impl Sync for ProgressReporter
impl Unpin for ProgressReporter
impl UnsafeUnpin for ProgressReporter
impl UnwindSafe for ProgressReporter
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