Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

jaboatman/tokio-scoped

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tokio-scoped

Please Consider Using async_scoped instead.

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!");
}

About

Scoped Runtime for tokio

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages