tokio-blocking
A thin wrapper to provide a simple interface to insert blocking operations between non-blocking operations in the context of futures.
let mut runtime = new.unwrap;
let pool = new;
let task = lazy
.and_then
.and_then_block
.and_then;
runtime.block_on.unwrap;
This crate was born because the existing blocking:
- requires much boilerplate.
- blocks the entire task after all (e.g.
selectdoesn't work well).
Combinators
The following combinators are supported. All of them takes two arguments: one is the handle of the thread pool which takes care of the blocking operation
, and the other is the callback to be called after the blocking operation gets completed. The type of the return value of the callback is Result.
It's passed to to the subsequent combinators as the normal combinators (such as and_then) do.
and_then_blockor_else_blockthen_block