@@ -34,7 +34,6 @@ import Swift
3434public protocol Clock < Duration> : Sendable {
3535 associatedtype Duration
3636 associatedtype Instant : InstantProtocol where Instant. Duration == Duration
37- associatedtype CanonicalClock : Clock = Self
3837
3938 var now : Instant { get }
4039 var minimumResolution : Instant . Duration { get }
@@ -76,58 +75,6 @@ public protocol Clock<Duration>: Sendable {
7675 on executor: some Executor ,
7776 at instant: Instant , tolerance: Duration ? )
7877#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 ?
13178}
13279
13380extension Clock {
@@ -150,40 +97,6 @@ extension Clock {
15097 }
15198}
15299
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-
187100@available ( StdlibDeploymentTarget 5 . 7 , * )
188101extension Clock {
189102 /// Measure the elapsed time to execute a closure.
@@ -258,6 +171,7 @@ extension Clock {
258171enum _ClockID : Int32 {
259172 case continuous = 1
260173 case suspending = 2
174+ case walltime = 3
261175}
262176
263177@available ( StdlibDeploymentTarget 5 . 7 , * )
0 commit comments