swift-nio icon indicating copy to clipboard operation
swift-nio copied to clipboard

Provide variants of the NIODeadline APIs (and maybe converters) that use `ContinuousClock`

Open Lukasa opened this issue 2 years ago • 0 comments

In Swift 5.7 the Clock protocol was added, including a concrete ContinuousClock type. This type corresponds nicely to the underlying clock type that SwiftNIO uses. As a result, ContinuousClock.Instant is approximately equivalent to NIODeadline. We should extend any API surface that uses NIODeadline to accept ContinuousClock.Instant.

Note that converting a ContinuousClock.Instant to a NIODeadline is tricky because ContinuousClock.Instant doesn't expose any underlying raw value we can operate on. We can do it by jumping through TimeAmount, and we should consider adding that API surface, but it'll be a bit slow so we should always prefer an explicit API that does the math directly on ContinuousClock.Instant.

Lukasa avatar Jun 14 '22 09:06 Lukasa