future-bool 0.1.1

A bool one can await the changes.
Documentation
  • Coverage
  • 77.78%
    7 out of 9 items documented0 out of 7 items with examples
  • Size
  • Source code size: 18.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.53 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 23s Average build duration of successful builds.
  • all releases: 23s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • devalain/future-bool
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • devalain

future-bool

crate docs

A bool one can await the changes.

Example usage

use future_bool::FutureBool;

#[tokio::main]
async fn main() {
    let run = FutureBool::new(false);
    let run_clone = run.clone();

    let task = tokio::spawn(async move {
        loop {
            // If run changes to false before `some_async_fn` is terminated, 
            // it will be interrupted.
            tokio::select! {
                _ = run_clone.wait_false() => break,
                _ = some_async_fn() => {}
            };
        }
    });

    // ... some other task sets run to false with 
    // `run.unset()`
    task.await;
}