Conversation
Sources/DistributedActors/Time.swift
Outdated
| public static func now() -> Deadline { | ||
| uptimeNanoseconds(Deadline.Value(DispatchTime.now().uptimeNanoseconds)) | ||
| public static var distantFuture: ContinuousClock.Instant { | ||
| .now() + Duration.effectivelyInfinite |
There was a problem hiding this comment.
Hmm I think so (and there are tests)? It used to be Deadline(Int64.max).
There was a problem hiding this comment.
I checked and these may end up with problematic edge cases...
It used to be that "distant future" was the absolute max value possible, but now that isn't it:
5> (Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max)).components
$R4: (seconds: Int64, attoseconds: Int64) = {
seconds = 18446744073
attoseconds = 709551614000000000
}
6> (Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max)).components
$R5: (seconds: Int64, attoseconds: Int64) = {
seconds = 27670116110
attoseconds = 564327421000000000
}
7> (Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max)).components
$R6: (seconds: Int64, attoseconds: Int64) = {
seconds = 36893488147
attoseconds = 419103228000000000
}
8> (Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max)).components
$R7: (seconds: Int64, attoseconds: Int64) = {
seconds = 46116860184
attoseconds = 273879035000000000
}
9> (Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max) + Duration.nanoseconds(Int64.max)).components
$R8: (seconds: Int64, attoseconds: Int64) = {
seconds = 55340232221
attoseconds = 128654842000000000
}
I think we may need to switch to Duration? and use nil as "potentially infinite"?
In other words we need to take care that the isEffectivelyInfinite works well... it is same as not having a timeout in most cases to be honest, so let's move to Duration? if that can work out?
There was a problem hiding this comment.
Strike all that I tried it out and it works out since we cap inside the .nanoseconds
Thank you!
ktoso
left a comment
There was a problem hiding this comment.
Looks great, only concern about potentially needing to mark extensions on Duration and the typealias internal so folks don't get upset we're adding public API to "not our type".
Resolves #955