Function tokio_scoped::scope [−][src]
pub fn scope<'a, F, R>(f: F) -> R where
F: FnOnce(&mut Scope<'a>) -> R,
Creates a ScopedRuntime
and calls the scope
method with f
on it.
Example
let mut v = String::from("Hello"); tokio_scoped::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!");