-
Notifications
You must be signed in to change notification settings - Fork 129
[IO_URING] Add support for pollAdd operation
#273
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
Open
FranzBusch
wants to merge
1
commit into
main
Choose a base branch
from
fb-io-uring-poll-add
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| This source file is part of the Swift System open source project | ||
|
|
||
| Copyright (c) 2020 Apple Inc. and the Swift System project authors | ||
| Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
|
||
| See https://swift.org/LICENSE.txt for license information | ||
| */ | ||
|
|
||
| #if compiler(>=6.2) && $Lifetimes | ||
| #if os(Linux) | ||
| extension IORing.Request { | ||
| /// A set of I/O events that can be monitored on a file descriptor. | ||
| /// | ||
| /// `PollEvents` represents the event mask used with io_uring poll operations to specify | ||
| /// which I/O conditions to monitor on a file descriptor. These events correspond to the | ||
| /// standard Posix poll events defined in the kernel's `poll.h` header. | ||
| /// | ||
| /// Use `PollEvents` with ``IORing/Request/pollAdd(_:pollEvents:isMultiShot:context:)`` | ||
| /// to register interest in specific I/O events. The poll operation completes when any of | ||
| /// the specified events become active on the file descriptor. | ||
| /// | ||
| /// ## Usage | ||
| /// | ||
| /// ```swift | ||
| /// // Monitor a socket for incoming data | ||
| /// let request = IORing.Request.pollAdd( | ||
| /// socketFD, | ||
| /// pollEvents: .pollin, | ||
| /// isMultiShot: true | ||
| /// ) | ||
| /// ``` | ||
| public struct PollEvents: OptionSet, Hashable, Codable { | ||
| public var rawValue: UInt32 | ||
|
|
||
| @inlinable | ||
| public init(rawValue: UInt32) { | ||
Catfish-Man marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| self.rawValue = rawValue | ||
| } | ||
|
|
||
| /// An event indicating data is available for reading. | ||
| /// | ||
| /// This event becomes active when data arrives on the file descriptor and can be read | ||
| /// without blocking. For sockets, this includes when a new connection is available on | ||
| /// a listening socket. Corresponds to the Posix `POLLIN` event flag. | ||
| @inlinable | ||
| public static var pollIn: PollEvents { PollEvents(rawValue: 0x0001) } | ||
|
|
||
| /// An event indicating the file descriptor is ready for writing. | ||
| /// | ||
| /// This event becomes active when writing to the file descriptor will not block. For | ||
| /// sockets, this indicates that send buffer space is available. Corresponds to the | ||
| /// Posix `POLLOUT` event flag. | ||
| @inlinable | ||
| public static var pollOut: PollEvents { PollEvents(rawValue: 0x0004) } | ||
| } | ||
| } | ||
| #endif | ||
| #endif | ||
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
Oops, something went wrong.
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.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know what you prefer and I am happy to change if needed. I am open to both.