tokio-scoped

Crates.iotokio-scoped
lib.rstokio-scoped
version0.2.0
sourcesrc
created_at2018-09-06 14:32:58.939478
updated_at2022-03-08 14:53:44.469998
descriptionScoped Runtime for tokio
homepagehttps://github.com/Snnappie/tokio-scoped
repositoryhttps://github.com/Snnappie/tokio-scoped
max_upload_size
id83177
size16,092
Jason Boatman (jaboatman)

documentation

README

tokio-scoped

tokio-scoped provides a scope function inspired by crossbeam but for the tokio Runtime. A scope allows one to spawn futures which do not have a 'static lifetime by ensuring each future spawned in the scope completes before the scope exits.

Example

#[tokio::main]
async fn main() {
    let mut v = String::from("Hello");
    tokio_scoped::scope(|scope| {
        // Use the scope to spawn the future.
        scope.spawn(async {
            v.push('!');
        });
    });
    // The scope won't exit until all spawned futures are complete.
    assert_eq!(v.as_str(), "Hello!");
}
Commit count: 26

cargo fmt