drop-awaiter 0.1.0

Library that allows you to asynchronously wait for something to be dropped
Documentation
  • Coverage
  • 25%
    1 out of 4 items documented1 out of 3 items with examples
  • Size
  • Source code size: 18.82 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.98 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 26s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ok-ul-ch/drop-awaiter
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ok-ul-ch

drop-awaiter

Library that allows you to asynchronously wait for something to be dropped.

Docs

Rustdoc

Examples

    struct Task {
        id: &'static str,
        dn: DropNotifier,
    }
 
    async fn foo() {
        let (n, awaiter) = crate::new();

        let first_task = Task {
            id: "first",
            dn: n.clone(),
        };
        std::thread::spawn(move || {
            std::thread::sleep(Duration::from_secs(5));
            println!("Completed task: {}", first_task.id);
            drop(first_task.dn);
        });

        let second_task = Task {
            id: "second",
            dn: n,
        };

        tokio::spawn(async move {
            tokio::time::sleep(Duration::from_secs(1)).await;
            println!("Completed task: {}", second_task.id);
            drop(second_task.dn);
        });

        // Simply await for completion of tasks (both sync and async) without 
        // any additional collections to coordinate and track statuses of tasks
        awaiter.await;
    }