Function tokio_scoped::scoped [−][src]
pub fn scoped(rt: &Runtime) -> ScopeBuilder
Borrows the Runtime to construct a ScopeBuilder
which can be used to create a scope.
Example
let mut v = String::from("Hello"); let rt = tokio::runtime::Runtime::new().unwrap(); tokio_scoped::scoped(&rt).scope(|scope| { // Use the scope to spawn the future. scope.spawn(lazy(|| { v.push('!'); Ok(()) })); }); // The scope won't exit until all spawned futures are complete. assert_eq!(v.as_str(), "Hello!");