Skip to content

Commit 5a572f5

Browse files
authored
Add Sendable annotations to SelectorGeneric (apple#3085)
### Motivation: Explicit Sendable requires a bunch of annotations in SelectorGeneric, as many of these types are `@usableFromInline`. This patch applies those. ### Modifications: - Make many types Sendable - Make some explicitly not Sendable ### Result: No missing Sendable warnings
1 parent 5ce7fde commit 5a572f5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Sources/NIOPosix/SelectorGeneric.swift

+10-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import CNIOLinux
2020
#endif
2121

2222
@usableFromInline
23-
internal enum SelectorLifecycleState {
23+
internal enum SelectorLifecycleState: Sendable {
2424
case open
2525
case closing
2626
case closed
@@ -60,7 +60,7 @@ extension timespec {
6060
/// If then suddenly the socket becomes both readable and writable, the eventing mechanism will tell you about that
6161
/// fact using `[.read, .write]`.
6262
@usableFromInline
63-
struct SelectorEventSet: OptionSet, Equatable {
63+
struct SelectorEventSet: OptionSet, Equatable, Sendable {
6464

6565
@usableFromInline
6666
typealias RawValue = UInt8
@@ -404,6 +404,9 @@ extension Selector: CustomStringConvertible {
404404
}
405405
}
406406

407+
@available(*, unavailable)
408+
extension Selector: Sendable {}
409+
407410
/// An event that is triggered once the `Selector` was able to select something.
408411
@usableFromInline
409412
struct SelectorEvent<R> {
@@ -422,6 +425,9 @@ struct SelectorEvent<R> {
422425
}
423426
}
424427

428+
@available(*, unavailable)
429+
extension SelectorEvent: Sendable {}
430+
425431
extension Selector where R == NIORegistration {
426432
/// Gently close the `Selector` after all registered `Channel`s are closed.
427433
func closeGently(eventLoop: EventLoop) -> EventLoopFuture<Void> {
@@ -473,7 +479,7 @@ extension Selector where R == NIORegistration {
473479

474480
/// The strategy used for the `Selector`.
475481
@usableFromInline
476-
enum SelectorStrategy {
482+
enum SelectorStrategy: Sendable {
477483
/// Block until there is some IO ready to be processed or the `Selector` is explicitly woken up.
478484
case block
479485

@@ -489,7 +495,7 @@ enum SelectorStrategy {
489495
/// to mark events to allow for filtering of received return values to not be delivered to a
490496
/// new `Registration` instance that receives the same file descriptor. Ok if it wraps.
491497
/// Needed for i.e. testWeDoNotDeliverEventsForPreviouslyClosedChannels to succeed.
492-
@usableFromInline struct SelectorRegistrationID: Hashable {
498+
@usableFromInline struct SelectorRegistrationID: Hashable, Sendable {
493499
@usableFromInline var _rawValue: UInt32
494500

495501
@inlinable var rawValue: UInt32 {

0 commit comments

Comments
 (0)