Skip to content

Commit 7eb3657

Browse files
authored
Merge pull request #59070 from phausler/pr/se-0329-notes
Add release notes for SE-0329: Clock, Instant, and Duration
2 parents 0b74559 + 2a4c268 commit 7eb3657

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
55

66
## Swift 5.7
77

8+
* [SE-0329][]:
9+
New types representing time and clocks were introduced. This includes a protocol `Clock` defining clocks which allow for defining a concept of now and a way to wake up after a given instant. Additionally a new protocol `InstantProtocol` for defining instants in time was added. Furthermore a new protocol `DurationProtocol` was added to define an elapsed duration between two given `InstantProtocol` types. Most commonly the `Clock` types for general use are the `SuspendingClock` and `ContinuousClock` which represent the most fundamental clocks for the system. The `SuspendingClock` type does not progress while the machine is suspended whereas the `ContinuousClock` progresses no matter the state of the machine.
10+
11+
```swift
12+
func delayedHello() async throws {
13+
try await Task.sleep(until: .now + .milliseconds(123), clock: .continuous)
14+
print("hello delayed world")
15+
}
16+
```
17+
18+
`Clock` also has methods to measure the elapsed duration of the execution of work. In the case of the `SuspendingClock` and `ContinuousClock` this measures with high resolution and is suitable for benchmarks.
19+
20+
```swift
21+
let clock = ContinuousClock()
22+
let elapsed = clock.measure {
23+
someLongRunningWork()
24+
}
25+
```
26+
827
* [SE-0309][]:
928

1029
Protocols with associated types and `Self` requirements can now be used as the
@@ -9354,6 +9373,7 @@ Swift 1.0
93549373
[SE-0326]: <https://github.com/apple/swift-evolution/blob/main/proposals/0326-extending-multi-statement-closure-inference.md>
93559374
[SE-0327]: <https://github.com/apple/swift-evolution/blob/main/proposals/0327-actor-initializers.md>
93569375
[SE-0328]: <https://github.com/apple/swift-evolution/blob/main/proposals/0328-structural-opaque-result-types.md>
9376+
[SE-0329]: <https://github.com/apple/swift-evolution/blob/main/proposals/0329-clock-instant-duration.md>
93579377
[SE-0331]: <https://github.com/apple/swift-evolution/blob/main/proposals/0331-remove-sendable-from-unsafepointer.md>
93589378
[SE-0333]: <https://github.com/apple/swift-evolution/blob/main/proposals/0333-with-memory-rebound.md>
93599379
[SE-0334]: <https://github.com/apple/swift-evolution/blob/main/proposals/0334-pointer-usability-improvements.md>

0 commit comments

Comments
 (0)