Open
Conversation
Collaborator
Mirko-von-Leipzig
left a comment
There was a problem hiding this comment.
Looks good, barring the notify change
| /// Used after an actor has shut down to detect the race where a notification arrived just as | ||
| /// the actor timed out; if so, the coordinator should respawn the actor. | ||
| fn has_pending_notification(&self) -> bool { | ||
| self.notify.max_capacity() > self.notify.capacity() |
Collaborator
There was a problem hiding this comment.
I assume you changed from Notify because you couldn't determine if it had a pending notification?
I think you should be able to something like the following
/// Returns `true` if there is an unread notification by the actor.
fn has_pending_notification(&self) -> bool {
use futures::FutureExt;
let mut fut = self.notify.notified();
if fut.now_or_never().is_ready() {
// Replace the notification to keep the state the same as before.
// Only required because fn signature doesn't consume.
self.notified.notify_one();
true
} else {
false
}
}
Collaborator
Author
There was a problem hiding this comment.
Yeah, exactly. The now_or_never trick didn't occur to me, so I went with mpsc::channel(1).
With this approach I can go back to Arc<Notify> with a little twist.
Mirko-von-Leipzig
requested changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #1889