Skip to main content

Module task

Module task 

Source
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:

§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§

SlabProgress
Read-only view of a background task’s progress.
SlabTask
Handle to a background slab operation.