mirror of
https://github.com/apple/swift-nio
synced 2026-11-28 05:14:23 +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
@@ -13,7 +13,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import XCTest
|
||||
import Dispatch
|
||||
import NIO
|
||||
import NIOHTTP1
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import XCTest
|
||||
import Dispatch
|
||||
import NIO
|
||||
import NIOHTTP1
|
||||
|
||||
|
||||
@@ -562,7 +562,7 @@ class HTTPUpgradeTestCase: XCTestCase {
|
||||
|
||||
// At this time we should have received one user event. We schedule this onto the
|
||||
// event loop to guarantee thread safety.
|
||||
XCTAssertNoThrow(try connectedServer.eventLoop.scheduleTask(in: .nanoseconds(0)) {
|
||||
XCTAssertNoThrow(try connectedServer.eventLoop.scheduleTask(deadline: .now()) {
|
||||
XCTAssertEqual(eventSaver.events.count, 1)
|
||||
if case .upgradeComplete(let proto, let req) = eventSaver.events[0] {
|
||||
XCTAssertEqual(proto, "myproto")
|
||||
|
||||
Reference in new issue
Block a user