32
32
#if compiler(>=6.0)
33
33
import Foundation
34
34
35
- public struct Timeout : Sendable {
35
+ @available ( * , unavailable, renamed: " TimeoutController " )
36
+ public typealias Timeout = TimeoutController
37
+
38
+ public struct TimeoutController : Sendable {
36
39
fileprivate var canary : @Sendable ( ) -> Void
37
40
fileprivate let shared : SharedState
38
41
@@ -74,7 +77,7 @@ public struct Timeout: Sendable {
74
77
}
75
78
76
79
@available ( macOS 13 . 0 , iOS 16 . 0 , tvOS 16 . 0 , watchOS 9 . 0 , * )
77
- public extension Timeout {
80
+ public extension TimeoutController {
78
81
79
82
@discardableResult
80
83
func expire< C: Clock > (
@@ -97,7 +100,7 @@ public extension Timeout {
97
100
}
98
101
}
99
102
100
- extension Timeout {
103
+ extension TimeoutController {
101
104
102
105
init (
103
106
canary: @escaping @Sendable ( ) -> Void ,
@@ -156,13 +159,13 @@ extension Timeout {
156
159
func withNonEscapingTimeout< T> (
157
160
_ timeout: @escaping @Sendable ( ) async throws -> Never ,
158
161
isolation: isolated ( any Actor ) ? = #isolation,
159
- body: ( Timeout ) async throws -> sending T
162
+ body: ( TimeoutController ) async throws -> sending T
160
163
) async throws -> sending T {
161
164
// canary ensuring Timeout does not escape at runtime.
162
165
// Swift 6.2 and later enforce at compile time with ~Escapable
163
166
try await withoutActuallyEscaping ( { @Sendable in } ) { escaping in
164
167
_ = isolation
165
- let timeout = Timeout ( canary: escaping, pending: timeout)
168
+ let timeout = TimeoutController ( canary: escaping, pending: timeout)
166
169
return try await Transferring ( body ( timeout) )
167
170
} . value
168
171
}
0 commit comments