Add a Monoio async runtime
Starting a work around AsyncRuntime to have a MonoioRuntime available & tested.
The main issue is around is_panic and abort right now, as to properly abort a task by using monoio, you need to cancel the IO with a Canceller.
⚠️ This a still a draft, the end idea is to have monoio available and this PR is also used to find out what steps are needed to achieve this. ⚠️
Checklist
- [ ] Updated guide with pertinent info (may not always apply).
- [ ] Squash down commits to one or two logical commits which clearly describe the work you've done.
- [ ] Unittest is a friend:)
Considerations
-
async-entry
worker_threadshave no impact onmonoiowith the current implementation ofasync-entry
References
- Issue linked: https://github.com/datafuselabs/openraft/issues/1011
BTW, we should probably make all required types part of the runtime, so tokio would be optional as well.
I do completely agree!
Currently, oneshot and mpsc channels as well as some other primitives are taken 1:1 from Tokio.
👍
Feel free to propose an API where you can pass the Canceller around properly. Can't it be part of a JoinHandle (i.e., wrap monoio::JoinHandle in a new type)?
Yeah, well, you need to have access to the Canceller when you want to abort the task, but you'll also need to have access to the Canceller when you do some IO related to io-uring when you are inside the spawned task, so you need it when you are spawning your task, something like this could be possible:
#[inline]
fn spawn<T>(fn: F) -> Self::JoinHandle<T::Output>
where
T: Future + OptionalSend + 'static,
T::Output: OptionalSend + 'static,
F: FnOnce(&AsyncRuntimeContext) -> T,
{
...
}
I'll try to have some ideas around, and it would be better to also have integration tests running on this new runtime too (linked to https://github.com/drmingdrmer/async-entry/issues/1 )
Fix OptionalSend usage:
- #1014