-
Notifications
You must be signed in to change notification settings - Fork 172
feat: add support for compio runtime #1364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this supplementary runtime support!
There should be a CI to ensure it pass the test, similar to:
https://github.com/datafuselabs/openraft/blob/00771c8db3dd274fbc2c7461e56960602b94931a/.github/workflows/ci.yaml#L270
Reviewed 10 of 10 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @George-Miao)
rt-compio/src/lib.rs
line 44 at r1 (raw file):
pub fn cancel(mut self) { // SAFETY: We are not using the JoinHandle anymore, so we can safely drop it. unsafe { ManuallyDrop::drop(&mut self.0) }
Since tasks are cancelled when their JoinHandle
is dropped, spawned compio tasks should use detach()
to keep them running in the background:
https://docs.rs/compio-runtime/0.7.0/compio_runtime/struct.Task.html#method.detach
OpenRaft only needs background tasks that run to completion without cancellation, so all spawned tasks can be detached. This eliminates the need for ManuallyDrop
wrappers around task handles.
Code quote:
pub fn cancel(mut self) {
// SAFETY: We are not using the JoinHandle anymore, so we can safely drop it.
unsafe { ManuallyDrop::drop(&mut self.0) }
Cargo.toml
line 63 at r1 (raw file):
"tests", "stores/memstore", "rt-compio"
A runtime does not have to be a member. Just put it in the following exclude
section.
The thing is, |
Hmm... I missed this point. Then it seems when |
That works too. I just need to wrap it with an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @George-Miao)
rt-compio/src/lib.rs
line 46 at r4 (raw file):
task.cancel(); } }
Why does it need a cancel
API? OpenRaft does not need to cancel a task.
If it allows user to cancel it, the following poll()
will just panic. Without it, everything looks good, right?
Code quote:
pub fn cancel(mut self) {
if let Some(task) = self.0.take() {
task.cancel();
}
}
rt-compio/src/lib.rs
line 73 at r4 (raw file):
impl<T> FusedFuture for CompioJoinHandle<T> { fn is_terminated(&self) -> bool { self.0.is_none()
Without cancel()
, it does not need to be fused any more.
Did I miss anything?
Code quote:
impl<T> FusedFuture for CompioJoinHandle<T> {
fn is_terminated(&self) -> bool {
self.0.is_none()
The internal handle is pub, so everyone can access and alter the state. I can remove all these and hide inner to users if you feel ok. |
Yes, it would be better. There is no need to leak internal non-required features to users. One more public features just introduces additional maintenance burden. |
fcc055c
to
7216e4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Reviewed 1 of 1 files at r6, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @George-Miao)
7216e4c
to
f12bb6c
Compare
There was a problem in the code, fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r8, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @George-Miao)
f12bb6c
to
7216e4c
Compare
Implement runtime support for compio asynchronous framework with core components: - Add CompioRuntime implementation of AsyncRuntime trait - Implement MPSC channels, oneshot, watch, and mutex primitives - Integrate with GitHub Actions workflow for CI testing - Add std::time::Instant implementation of Instant trait
7216e4c
to
e5ab722
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r10, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @George-Miao)
Checklist
This change is