Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Oct 25, 2023

This PR generalizes the storage of timestamps and durations using a new internal-only TimeValue type. This type represents any "seconds and subseconds" value such as a timespec, SuspendingClock.Instant, Duration, etc.

This type allows us to simplify the story for storing, handling, encoding, and decoding time values. Whereas previously we had a lot of conditionalized code like:

#if SWT_TARGET_OS_APPLE
doSomething(uptime)
#else
doSomethingSimilar(suspending)
#endif

We can now generally use the same code path for both.

@grynspan grynspan marked this pull request as ready for review October 25, 2023 16:54
@grynspan grynspan force-pushed the jgrynspan/generalize-time-types branch from 1d6041e to 295afc1 Compare October 25, 2023 17:02
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan grynspan added the enhancement New feature or request label Oct 25, 2023
This PR generalizes the storage of timestamps and durations using a new internal-only `TimeValue` type. This type represents any "seconds and subseconds" value such as a `timespec`, `SuspendingClock.Instant`, `Duration`, etc.

This type allows us to simplify the story for storing, handling, encoding, and decoding time values. Whereas previously we had a lot of conditionalized code like:

```swift
 #if SWT_TARGET_OS_APPLE
doSomething(uptime)
 #else
doSomethingSimilar(suspending)
 #endif
```

We can now generally use the same code path for both.
@grynspan grynspan force-pushed the jgrynspan/generalize-time-types branch from 295afc1 to d7d55cc Compare October 25, 2023 21:08
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan grynspan merged commit 7c5c0b8 into main Oct 25, 2023
@grynspan grynspan deleted the jgrynspan/generalize-time-types branch October 25, 2023 21:16
stmontgomery added a commit to stmontgomery/swift-testing that referenced this pull request Oct 27, 2023
This extends the `TimeValue` type added in swiftlang#83 by allowing conversion to
`timespec`. It then adopts that in a couple places to ensure consistency.
stmontgomery added a commit that referenced this pull request Oct 27, 2023
This extends the `TimeValue` type added in #83 by allowing conversion to
`timespec`. It then adopts that in a couple places to ensure consistency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants