Expand description
impedance
is a library that provides utilities to make working with blocking code while in
the context of asynchronous code easier. It is named after this
phenomenom.
§Utilities
A wrapper around blocking work that can adaptively move that work to another thread when it is
expensive (where expensive == long wall-time). It works in tandem with its configuration
mechanism Token
. This can sometimes give us the best of both worlds:
ⓘ
$ cargo +nightly bench
...
test fast_with_adaptive ... bench: 4,782 ns/iter (+/- 627)
test fast_with_adaptive_always_inline ... bench: 4,412 ns/iter (+/- 699)
test fast_with_adaptive_always_spawn ... bench: 55,455 ns/iter (+/- 22,798)
test fast_with_nothing ... bench: 3,391 ns/iter (+/- 227)
test fast_with_spawn_blocking ... bench: 51,054 ns/iter (+/- 10,620)
test slow_with_adaptive ... bench: 12,092,260 ns/iter (+/- 1,572,018)
test slow_with_nothing ... bench: 122,687,873 ns/iter (+/- 16,353,904)
test slow_with_spawn ... bench: 24,730,260 ns/iter (+/- 3,003,759)
test slow_with_spawn_blocking ... bench: 12,543,033 ns/iter (+/- 2,753,322)
...
(See the benchmarks themselves for more info)
buffer_unordered/buffered
helpers (coming hopefully soon) Helpers that avoid pitfalls when usingbuffer_unordered
.
§Features
This library should be design in a way such that any executor that has a
spawn_blocking
method can be used:
tokio
: Currently this library tries to provide good support fortokio
which is in itsdefault_features
.async-std-experimental
: This library has experimental support for usingasync-std
(as well asfutures
internally for a oneshot channel). You will need to usedefault-features = false
and there are caveats: First and foremost, panic payloads’s are NOT ALWAYS propagated correctly, they have a default failed task message when the work was moved to a thread.- TODO: consider
async_executors
for this abstraction
- TODO: consider
Modules§
- Adaptively schedule blocking work