calloop icon indicating copy to clipboard operation
calloop copied to clipboard

More Readiness events?

Open vikigenius opened this issue 1 year ago • 3 comments

I see that Mio has support for:

is_read_closed

is_write_closed

Can we get that in Calloop as well?

I am trying to use a client server architecture with Unix Sockets. Multiple clients can connect to the server. In rust every time there is a new connection to UnixListener it get's it's own UnixStream. I would like to keep track of connections so that I can send messages to appropriate streams.

But I also need to detect when the stream has been shutdown and we know that we won't receive anymore data in it.

Is there a reason why these aren't implemented? It seems like Mio does it using EPOLLHUP, EPOLLIN, EPOLLRDHUP. Is there a way to achieve this in calloop already that I don't know about?

vikigenius avatar Jul 25 '24 01:07 vikigenius

polling has support for is_interrupt (usually corresponds to HUP), which I think fits the bill here.

notgull avatar Jul 26 '24 00:07 notgull

@notgull Seems like it, looks like it maintains an extra field

/// Indicates that a file descriptor or socket can read or write without blocking.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Event {
    /// Key identifying the file descriptor or socket.
    pub key: usize,
    /// Can it do a read operation without blocking?
    pub readable: bool,
    /// Can it do a write operation without blocking?
    pub writable: bool,
    /// System-specific event data.
    extra: sys::EventExtra,
}

Can calloop do something similar by maintaining an extra field in the Readiness struct and implementing is_interrupt using that? I am willing to contribute if this is something that you are interested in? I don't think this should be a breaking change?

vikigenius avatar Jul 26 '24 04:07 vikigenius

I am willing to contribute if this is something that you are interested in?

Sorry for the delay. Yes I would be interested.

notgull avatar Sep 06 '24 02:09 notgull