[−][src]Function async_scoped::scope_and_block
pub fn scope_and_block<'a, T: Send + 'static, R, F: FnOnce(&mut Scope<'a, T>) -> R>(
f: F
) -> (R, Vec<T>)
A function that creates a scope and immediately awaits,
blocking the current thread for spawned futures to
complete. The outputs of the futures are collected as a
Vec
and returned along with the output of the block.
Safety
This function is safe to the best of our understanding as it blocks the current thread until the stream is driven to completion, implying that all the spawned futures have completed too. However, care must be taken to ensure a recursive usage of this function doesn't lead to deadlocks.
When scope is used recursively, you may also use the
unsafe scope_and_*
functions as long as this function
is used at the top level. In this case, either the
recursively spawned should have the same lifetime as the
top-level scope, or there should not be any spurious
future cancellations within the top level scope.