Expand description
Thread-based asynchronous task execution with progress polling.
This module provides SlabTask and SlabProgress for running
long-lived slab operations (bulk reads, bulk writes) on a background
thread while the caller polls for progress.
§Architecture
Since the crate has no async runtime dependency, background work is
dispatched via std::thread::spawn. The caller receives a
SlabTask<T> handle that exposes:
SlabTask::progress— aSlabProgresssnapshot (total items, completed items, done flag)SlabTask::is_done— quick check without joiningSlabTask::wait— blocks until the background thread finishes and returns the result
§Example
use slabtastic::task::{SlabProgress, SlabTask};
// (Typically you'd get a SlabTask from SlabReader::read_to_sink_async
// or SlabWriter::write_from_iter_async — this is a conceptual sketch.)
while !task.is_done() {
let p = task.progress();
println!("{}/{} ({:.1}%)", p.completed(), p.total(),
p.fraction() * 100.0);
std::thread::sleep(std::time::Duration::from_millis(100));
}
let result = task.wait().expect("task succeeded");
println!("done — processed {result} records");Structs§
- Slab
Progress - Read-only view of a background task’s progress.
- Slab
Task - Handle to a background slab operation.