@@ -34,7 +34,6 @@ import Swift
34
34
public protocol Clock < Duration> : Sendable {
35
35
associatedtype Duration
36
36
associatedtype Instant : InstantProtocol where Instant. Duration == Duration
37
- associatedtype CanonicalClock : Clock = Self
38
37
39
38
var now : Instant { get }
40
39
var minimumResolution : Instant . Duration { get }
@@ -76,58 +75,6 @@ public protocol Clock<Duration>: Sendable {
76
75
on executor: some Executor ,
77
76
at instant: Instant , tolerance: Duration ? )
78
77
#endif
79
-
80
- /// Obtain the equivalent, canonical clock, or `nil` if this clock
81
- /// is already canonical.
82
- ///
83
- /// A non-canonical clock is a clock with some relationship to a base,
84
- /// canonical, clock, to which it can be converted.
85
- @available ( StdlibDeploymentTarget 6 . 2 , * )
86
- var canonicalClock : CanonicalClock ? { get }
87
-
88
- /// Convert an Instant to the canonical clock's equivalent Instant.
89
- ///
90
- /// Parameters:
91
- ///
92
- /// - instant: The `Instant` to convert.
93
- ///
94
- /// Returns:
95
- ///
96
- /// The equivalent `CanonicalClock.Instant`.
97
- func convertToCanonical( instant: Instant ) -> CanonicalClock . Instant
98
-
99
- /// Convert a Duration to the canonical clock's equivalent Duration.
100
- ///
101
- /// Parameters:
102
- ///
103
- /// - duration: The `Duration` to convert.
104
- ///
105
- /// Returns:
106
- ///
107
- /// The equivalent `CanonicalClock.Duration`.
108
- func convertToCanonical( duration: Duration ) -> CanonicalClock . Duration
109
-
110
- /// Convert an Instant to the canonical clock's equivalent Instant.
111
- ///
112
- /// Parameters:
113
- ///
114
- /// - instant: The `Instant` to convert, or `nil`.
115
- ///
116
- /// Returns:
117
- ///
118
- /// The equivalent `CanonicalClock.Instant`, or `nil` if `instant` was `nil`.
119
- func maybeConvertToCanonical( instant: Instant ? ) -> CanonicalClock . Instant ?
120
-
121
- /// Convert a Duration to the canonical clock's equivalent Duration.
122
- ///
123
- /// Parameters:
124
- ///
125
- /// - duration: The `Duration` to convert, or `nil`.
126
- ///
127
- /// Returns:
128
- ///
129
- /// The equivalent `CanonicalClock.Duration`, or `nil` if `duration` was `nil`.
130
- func maybeConvertToCanonical( duration: Duration ? ) -> CanonicalClock . Duration ?
131
78
}
132
79
133
80
extension Clock {
@@ -150,40 +97,6 @@ extension Clock {
150
97
}
151
98
}
152
99
153
- // Default implementations for canonicalization support
154
- extension Clock where CanonicalClock == Self {
155
- public var canonicalClock : CanonicalClock ? { return nil }
156
-
157
- public func convertToCanonical( duration: Duration ) -> CanonicalClock . Duration {
158
- return duration
159
- }
160
-
161
- public func convertToCanonical( instant: Instant ) -> CanonicalClock . Instant {
162
- return instant
163
- }
164
- }
165
-
166
- // nil-propagating versions of convertToCanonical()
167
- extension Clock {
168
- public func maybeConvertToCanonical( duration: Duration ? )
169
- -> CanonicalClock . Duration ?
170
- {
171
- if let duration {
172
- return convertToCanonical ( duration: duration)
173
- }
174
- return nil
175
- }
176
-
177
- public func maybeConvertToCanonical( instant: Instant ? )
178
- -> CanonicalClock . Instant ?
179
- {
180
- if let instant {
181
- return convertToCanonical ( instant: instant)
182
- }
183
- return nil
184
- }
185
- }
186
-
187
100
@available ( StdlibDeploymentTarget 5 . 7 , * )
188
101
extension Clock {
189
102
/// Measure the elapsed time to execute a closure.
@@ -258,6 +171,7 @@ extension Clock {
258
171
enum _ClockID : Int32 {
259
172
case continuous = 1
260
173
case suspending = 2
174
+ case walltime = 3
261
175
}
262
176
263
177
@available ( StdlibDeploymentTarget 5 . 7 , * )
0 commit comments