Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianfett committed Jul 8, 2021
1 parent 834d0d5 commit fc1ff51
Showing 1 changed file with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,34 @@
import NIO

extension HTTPConnectionPool {
struct Waiter {
struct ID: Hashable {
private let objectIdentifier: ObjectIdentifier
struct RequestID: Hashable {
private let objectIdentifier: ObjectIdentifier

init(_ request: HTTPScheduledRequest) {
self.objectIdentifier = ObjectIdentifier(request)
}
init(_ request: HTTPScheduledRequest) {
self.objectIdentifier = ObjectIdentifier(request)
}
}

var id: ID {
ID(self.request)
struct Waiter {
var requestID: RequestID {
RequestID(self.request)
}

var request: HTTPScheduledRequest {
didSet {
self.updateEventLoopRequirement()
var request: HTTPScheduledRequest

private var eventLoopRequirement: EventLoop? {
switch self.request.eventLoopPreference.preference {
case .delegateAndChannel(on: let eventLoop),
.testOnly_exact(channelOn: let eventLoop, delegateOn: _):
return eventLoop
case .delegate(on: _),
.indifferent:
return nil
}
}

private var eventLoopRequirement: EventLoop?

init(request: HTTPScheduledRequest) {
self.request = request
self.updateEventLoopRequirement()
}

func canBeRun(on option: EventLoop) -> Bool {
Expand All @@ -49,16 +53,5 @@ extension HTTPConnectionPool {

return requirement === option
}

private mutating func updateEventLoopRequirement() {
switch self.request.eventLoopPreference.preference {
case .delegateAndChannel(on: let eventLoop),
.testOnly_exact(channelOn: let eventLoop, delegateOn: _):
self.eventLoopRequirement = eventLoop
case .delegate(on: _),
.indifferent:
self.eventLoopRequirement = nil
}
}
}
}

0 comments on commit fc1ff51

Please sign in to comment.