mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Add deadlines as an alternative to timeouts (#770)
Add deadlines as an alternative to timeouts Motivation: Address #603 Modifications: - Add NIODeadline type - Add func scheduleTask<T>(deadline: NIODeadline, _ task: @escaping () throws -> T) -> Scheduled<T> - Reduce the use of DispatchTime in favor of Time - Replace timeout calls with deadline calls where it makes sense Result: Tasks can be scheduled after an amount of time has passed, or at a certain time.
This commit is contained in:
1 parent
de8d3e260e
commit
0eb85a4478
13 files changed
+172
-76
No files matched your search
@@ -12,7 +12,6 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Dispatch
|
||||
import NIO
|
||||
import NIOHTTP1
|
||||
import NIOWebSocket
|
||||
@@ -145,7 +144,7 @@ private final class WebSocketTimeHandler: ChannelInboundHandler {
|
||||
|
||||
// We can't really check for error here, but it's also not the purpose of the
|
||||
// example so let's not worry about it.
|
||||
let theTime = DispatchTime.now().uptimeNanoseconds
|
||||
let theTime = NIODeadline.now().uptimeNanoseconds
|
||||
var buffer = ctx.channel.allocator.buffer(capacity: 12)
|
||||
buffer.write(string: "\(theTime)")
|
||||
|
||||
|
||||
Reference in new issue
Block a user