mirror of
https://github.com/apple/swift-system
synced 2026-11-24 04:38:14 +00:00
Doc comment updates
This commit is contained in:
4 files changed
+42
-21
No files matched your search
@@ -60,7 +60,9 @@ public extension IORing.Completion {
|
||||
/// for a read or a write, an event mask for a poll, and so on.
|
||||
///
|
||||
/// A negative value is an `errno` code multiplied by -1. Recover the error
|
||||
/// by negating it again: `Errno(rawValue: -completion.result)`.
|
||||
/// by negating it again: `Errno(rawValue: -completion.result)`. Only
|
||||
/// ``IORing/tryConsumeCompletion()`` returns completions with a negative
|
||||
/// result; the blocking methods report the error as an ``Errno`` instead.
|
||||
@inlinable var result: Int32 {
|
||||
get {
|
||||
rawValue.res
|
||||
|
||||
@@ -217,7 +217,7 @@ extension IORing.Request {
|
||||
/// Adds a poll operation to monitor a file descriptor for specific I/O
|
||||
/// events.
|
||||
///
|
||||
/// This method creates an io_uring poll operation that monitors the
|
||||
/// This method creates an `io_uring` poll operation that monitors the
|
||||
/// specified file descriptor for I/O readiness events. The operation
|
||||
/// completes when any of the requested events occur on the file
|
||||
/// descriptor, such as data becoming available for reading or the
|
||||
@@ -225,17 +225,24 @@ extension IORing.Request {
|
||||
///
|
||||
/// Poll operations are useful for implementing efficient I/O
|
||||
/// multiplexing, allowing you to monitor multiple file descriptors
|
||||
/// concurrently within a single io_uring instance. When used with
|
||||
/// concurrently within a single `io_uring` instance. When used with
|
||||
/// multishot mode, a single poll operation can deliver multiple
|
||||
/// completion events without needing to be resubmitted.
|
||||
///
|
||||
/// Poll requests on a ring created with
|
||||
/// ``IORing/SetupFlags/pollCompletions`` fail with
|
||||
/// ``Errno/invalidArgument``.
|
||||
///
|
||||
/// ## Multishot Behavior
|
||||
///
|
||||
/// When `isMultiShot` is `true`, the poll operation automatically rearms
|
||||
/// after each completion event, continuing to monitor the file descriptor
|
||||
/// for subsequent events. This reduces submission overhead for long-lived
|
||||
/// monitoring operations. The operation continues until explicitly
|
||||
/// cancelled or the file descriptor is closed.
|
||||
/// monitoring operations. The poll stays armed until it's canceled or the
|
||||
/// kernel ends it; its last completion is the one without
|
||||
/// ``IORing/Completion/Flags/moreCompletions``. Neither a hangup nor
|
||||
/// closing the descriptor ends the poll, and the request keeps the file
|
||||
/// open until the poll ends.
|
||||
///
|
||||
/// When `isMultiShot` is `false`, the poll operation completes once after
|
||||
/// the first matching event occurs, requiring resubmission to continue
|
||||
@@ -262,13 +269,19 @@ extension IORing.Request {
|
||||
/// var armed = true
|
||||
/// while armed {
|
||||
/// let completion = try ring.blockingConsumeCompletion()
|
||||
/// armed = completion.flags.contains(.moreCompletions)
|
||||
/// if completion.context == 1 {
|
||||
/// // Handle incoming connection
|
||||
/// guard completion.context == 1 else {
|
||||
/// // Handle completions for other requests.
|
||||
/// continue
|
||||
/// }
|
||||
/// armed = completion.flags.contains(.moreCompletions)
|
||||
/// // Handle incoming connection
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// If the poll ends with an error, such as ``Errno/canceled``,
|
||||
/// ``IORing/blockingConsumeCompletion(timeout:)`` throws that error
|
||||
/// instead of returning the completion.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - file: The file descriptor to monitor for I/O events.
|
||||
/// - events: The I/O events to monitor on the file descriptor.
|
||||
@@ -286,7 +299,8 @@ extension IORing.Request {
|
||||
/// ## See Also
|
||||
///
|
||||
/// - ``PollEvents``: The events that can be monitored.
|
||||
/// - ``IORing/Request/cancel(_:matching:)``: Cancelling poll operations.
|
||||
/// - ``IORing/Request/cancel(_:matching:)-(_,FileDescriptor)``:
|
||||
/// Canceling poll operations.
|
||||
@inlinable public static func pollAdd(
|
||||
_ file: FileDescriptor,
|
||||
events: PollEvents,
|
||||
|
||||
@@ -51,8 +51,8 @@ extension UnsafeMutableRawBufferPointer {
|
||||
}
|
||||
|
||||
/// Owns the FilePaths whose interior pointers have been written into pending
|
||||
/// SQEs. The kernel copies SQE-referenced data out during io_uring_enter (due to
|
||||
/// IORING_FEAT_SUBMIT_STABLE), so the paths only need to live across the prepare->submit gap
|
||||
/// SQEs. The kernel copies SQE-referenced data out during `io_uring_enter` (due to
|
||||
/// `IORING_FEAT_SUBMIT_STABLE`), so the paths only need to live across the prepare->submit gap
|
||||
/// This is a class purely to avoid making methods calling `pin` mutating, which would be an API break
|
||||
@usableFromInline
|
||||
internal final class PendingPathBuffers {
|
||||
@@ -885,7 +885,7 @@ public struct IORing: ~Copyable {
|
||||
return true
|
||||
}
|
||||
|
||||
/// Describes which io_uring features are supported by the kernel this program is running on
|
||||
/// Describes which `io_uring` features are supported by the kernel this program is running on
|
||||
public struct Features: OptionSet, RawRepresentable, Hashable {
|
||||
public let rawValue: UInt32
|
||||
|
||||
@@ -911,7 +911,7 @@ public struct IORing: ~Copyable {
|
||||
@inlinable public static var bundledSendReceive: Features { .init(rawValue: UInt32(1) << 14) } //IORING_FEAT_RECVSEND_BUNDLE
|
||||
}
|
||||
|
||||
/// Describes which io_uring features are supported by the kernel this program is running on
|
||||
/// Describes which `io_uring` features are supported by the kernel this program is running on
|
||||
public var supportedFeatures: Features {
|
||||
return features
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
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
|
||||
/// `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.
|
||||
@@ -104,7 +104,7 @@ extension IORing.Request {
|
||||
///
|
||||
/// The kernel reports this event whether or not it was requested, and
|
||||
/// requesting it explicitly has no effect. Corresponds to the POSIX
|
||||
/// `POLLHUP` event flag.v
|
||||
/// `POLLHUP` event flag.
|
||||
public static var hangUp: PollEvents { PollEvents(.hangUp) }
|
||||
|
||||
/// An event indicating that the object a descriptor refers to is no
|
||||
@@ -114,8 +114,8 @@ extension IORing.Request {
|
||||
/// refers to has since become invalid. For example, the disconnection
|
||||
/// of a sound device could cause this event.
|
||||
///
|
||||
/// Note that a descriptor which simply does not resolve would
|
||||
/// return the EBADF error code (Errno.badFileDescriptor).
|
||||
/// A descriptor that doesn't resolve at all would make the request
|
||||
/// fail with ``Errno/badFileDescriptor`` instead.
|
||||
///
|
||||
/// The kernel reports this event whether or not it was requested, and
|
||||
/// requesting it explicitly has no effect. Corresponds to the POSIX
|
||||
@@ -128,9 +128,14 @@ extension IORing.Request {
|
||||
/// An event indicating the peer closed its writing end of a stream
|
||||
/// socket, or shut it down for writing.
|
||||
///
|
||||
/// Unlike ``hangUp``, this event leaves the connection half-open: data
|
||||
/// already in flight can still be read, and the local end can still
|
||||
/// write. Corresponds to the Linux `POLLRDHUP` event flag.
|
||||
/// Unlike ``hangUp``, this event can arrive while the connection is
|
||||
/// still half-open: data already in flight can still be read, and the
|
||||
/// local end can still write. Once both directions are shut down,
|
||||
/// ``hangUp`` is reported alongside this event.
|
||||
///
|
||||
/// Unlike `poll(2)`, `io_uring` reports this event whether or not it
|
||||
/// was requested, and requesting it explicitly has no effect.
|
||||
/// Corresponds to the Linux `POLLRDHUP` event flag.
|
||||
@inlinable
|
||||
public static var peerClosed: PollEvents { PollEvents(.peerClosed) }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user