[IO_URING] Add support for pollAdd operation - #273
Conversation
|
@swift-ci please test |
c64fc9c to
e69d5c1
Compare
|
@swift-ci please test |
Catfish-Man
left a comment
There was a problem hiding this comment.
I had a few comments but I don't think any of them are necessarily blockers
| /// | ||
| /// - ``PollEvents``: The events that can be monitored. | ||
| /// - ``IORing/Request/cancel(_:matching:)``: Cancelling poll operations. | ||
| @inlinable public static func pollAdd( |
There was a problem hiding this comment.
Typically Swift naming style would be verb-first but if there's a good reason to have it this way it's probably fine
There was a problem hiding this comment.
I was trying to match what the io_uring operation was called. I wasn't sure how much we tried to change the naming to fit our Swift naming guidelines.
There was a problem hiding this comment.
I guessed that was probably what you were doing. I remember this coming up during the initial proposal review and iirc folks leaned "don't try to make the names friendlier" so that looking up docs will work better. I'm still torn on it but I see the logic.
There was a problem hiding this comment.
Let me know what you prefer and I am happy to change if needed. I am open to both.
There was a problem hiding this comment.
pollAdd is somewhat greppable with io_uring docs, but not directly since the names are usually something like io_uring_prep_poll_add or IORING_OP_POLL_ADD. This is the name for the request, so maybe just poll would be better: poll(fd, events: PollEvents, isMultiShot: Bool, context: UInt64).
A future addition would be removal of events, and the constant used for that in the C library is IORING_POLL_UPDATE_EVENTS. I don't think we would want pollUpdate or pollRemove, maybe just update.
e69d5c1 to
5353528
Compare
|
@swift-ci please test |
1 similar comment
|
@swift-ci please test |
|
@swift-ci please test |
glessard
left a comment
There was a problem hiding this comment.
I'd be inclined to approve this addition if that were our process.
|
@swift-ci please test |
To observe events on file descriptors IO_URING supports the `pollAdd` operation. This is useful when you want to observe a file descriptor becoming ready to read or write This PR adds a new `IORing.Request.PollEvents` option set to model the poll masks. Furthermore, it adds a new `static func pollAdd` to the `IORing.Request`. We can now use IO_URING to poll for events on file descriptors.
Co-authored-by: Martin <sebastian.toivonen@gmail.com>
9dfe6c6 to
5a94258
Compare
|
@swift-ci please test |
| case pollOut = 0x0004 | ||
| case pollErr = 0x0008 | ||
| case pollHup = 0x0010 | ||
| case pollNval = 0x0020 |
There was a problem hiding this comment.
Added cases for POLLHUP and POLLNVAL. These names are inscrutable in any situation. Should they be pollHup and pollNval, or pollHangup and pollInvalid, or hangUp and invalidDescriptor. For now I continued along with the earlier work in this PR and used what I consider to be the bad names.
Missing are POLLPRI and POLLRDHUP, which would be relevant for sockets.
Better names would be readable, writable, error, hangUp, invalidDescriptor (+ priorityData, and peerClosed)
5a94258 to
d4373e3
Compare
|
@swift-ci please test |
|
Public symbols added in this PR: struct IORing.Request.PollEvents: OptionSet, Hashable, Codable, CaseIterable {
init(rawValue: UInt32)
static var allCases: [PollEvents]
static var pollIn // 0x0001
static var pollOut // 0x0004
static var pollErr // 0x0008
static var pollHup // 0x0010
static var pollNval // 0x0020
}
extension IORing.Request {
static func pollAdd(_:pollEvents:isMultiShot:context:)
}Let's figure out whether these are the names we want. I think the presence of I believe having some accessors on |
Many more additions made, requested a new review.
I think this is a good suggestion and just renaming them to
Similarly here I personally think that sticking as close to the libuiring and ops code naming is beneficial when it comes to discovery. |
Motivation
To observe events on file descriptors IO_URING supports the
pollAddoperation. This is useful when you want to observe a file descriptor becoming ready to read or writeModifications
This PR adds a new
IORing.Request.PollEventsoption set to model the poll masks. Furthermore, it adds a newstatic func pollAddto theIORing.Request.Result
We can now use IO_URING to poll for events on file descriptors.