@@ -51,7 +51,7 @@ extension NIOSerialEventLoopExecutor {
51
51
/// This type is not recommended for use because it risks problems with unowned
52
52
/// executors. Adopters are recommended to conform their own event loop
53
53
/// types to `SerialExecutor`.
54
- final class NIODefaultSerialEventLoopExecutor {
54
+ final class NIODefaultEventLoopExecutor {
55
55
@usableFromInline
56
56
let loop : EventLoop
57
57
@@ -62,7 +62,7 @@ final class NIODefaultSerialEventLoopExecutor {
62
62
}
63
63
64
64
@available ( macOS 14 . 0 , iOS 17 . 0 , watchOS 10 . 0 , tvOS 17 . 0 , * )
65
- extension NIODefaultSerialEventLoopExecutor : SerialExecutor {
65
+ extension NIODefaultEventLoopExecutor : SerialExecutor {
66
66
@inlinable
67
67
public func enqueue( _ job: consuming ExecutorJob ) {
68
68
self . loop. enqueue ( job)
@@ -71,12 +71,42 @@ extension NIODefaultSerialEventLoopExecutor: SerialExecutor {
71
71
@inlinable
72
72
public func asUnownedSerialExecutor( ) -> UnownedSerialExecutor {
73
73
UnownedSerialExecutor ( complexEquality: self )
74
-
75
74
}
76
75
77
76
@inlinable
78
- public func isSameExclusiveExecutionContext( other: NIODefaultSerialEventLoopExecutor ) -> Bool {
77
+ public func isSameExclusiveExecutionContext( other: NIODefaultEventLoopExecutor ) -> Bool {
79
78
self . loop === other. loop
80
79
}
81
80
}
82
81
#endif
82
+
83
+ #if compiler(>=6.0)
84
+ /// A helper protocol that can be mixed in to a NIO ``EventLoop`` to provide an
85
+ /// automatic conformance to `TaskExecutor`.
86
+ ///
87
+ /// Implementers of `EventLoop` should consider conforming to this protocol as
88
+ /// well on Swift 6.0 and later.
89
+ @available ( macOS 9999 . 0 , iOS 9999 . 0 , watchOS 9999 . 0 , tvOS 9999 . 0 , * )
90
+ public protocol NIOTaskEventLoopExecutor : NIOSerialEventLoopExecutor & TaskExecutor { }
91
+
92
+ @available ( macOS 9999 . 0 , iOS 9999 . 0 , watchOS 9999 . 0 , tvOS 9999 . 0 , * )
93
+ extension NIOTaskEventLoopExecutor {
94
+ @inlinable
95
+ func asUnownedTaskExecutor( ) -> UnownedTaskExecutor {
96
+ UnownedTaskExecutor ( ordinary: self )
97
+ }
98
+
99
+ @inlinable
100
+ public var taskExecutor : any TaskExecutor {
101
+ self
102
+ }
103
+ }
104
+
105
+ @available ( macOS 9999 . 0 , iOS 9999 . 0 , watchOS 9999 . 0 , tvOS 9999 . 0 , * )
106
+ extension NIODefaultEventLoopExecutor : TaskExecutor {
107
+ @inlinable
108
+ public func asUnownedTaskExecutor( ) -> UnownedTaskExecutor {
109
+ UnownedTaskExecutor ( ordinary: self )
110
+ }
111
+ }
112
+ #endif
0 commit comments