[][src]Function futures_ext::closure_to_blocking_future

pub fn closure_to_blocking_future<T, E, Func>(
    f: Func
) -> impl Future<Item = T, Error = E> where
    Func: FnMut() -> Result<T, E>,
    E: From<BlockingError>, 

Given an FnMut closure, create a Future that will eventually execute the closure using Tokio's blocking mechanism, so that it is safe to call blocking code inside the closure without preventing other tasks from making progress. This returns a lazy future - it will not even attempt to run the blocking code until you poll the future. Note that this does not spawn the future onto its own task - use asynchronize below if you need to run the blocking code on its own thread, rather than letting it block this task.