-
Notifications
You must be signed in to change notification settings - Fork 118
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
Allow users to create Notifier objects when handling requests #303
Conversation
2dc19bc
to
3eefa9a
Compare
This doesn't seem like the right place to create a |
Sure, for example here: https://github.com/colinmarc/southpaw/blob/main/src/fs.rs#L350-L354 Each |
I haven't actually used the notification interface myself, but my understanding is that a If it was available in |
I guess so, but I'd just be wrapping it in an If you'd like to provide a tighter interface, instead, we could create a scoped object, something like struct PollHandle {
pub ph: u64
notifier: Notifier
}
impl PollHandle {
pub fn notify(self) -> io::Result<()> {
self.notifier.poll(self.ph)
}
} And pass it in instead of |
That does seem better to me. I haven't used notification myself, but as I understand it there are two distinct use cases:
Are there any other cases I'm missing? The thing I want to avoid is adding a notifier to all requests, because many requests don't need a notifier |
This allows filesystems to respond directly to poll requests without having saved a notifier at session creation time.
Updated to add the |
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!
This is often useful in
poll
implementations. It also comes into play in #300, because your initialization and setup (when you can callSession::notifier
) is often separate from creating the session.