Skip to main content

block_on_or_add_subtask

Function block_on_or_add_subtask 

Source
pub fn block_on_or_add_subtask<Fut>(future: Fut) -> Option<Fut::Output>
where Fut: Future + Send + 'static, Fut::Output: Send + 'static,
Expand description

Blocks on future in one way or another if possible.

IO & time related Futures must be handled within their own Context. Wait for the result using a JoinHandle or a channel.

If there’s currently an active Context with a task, then the future is only queued up as a pending sub task for that task.

Otherwise the current thread is blocking and the passed in future is executed.

Note that you must not pass any futures here that wait for the currently active task in one way or another as this would deadlock!