diff --git a/Sources/NIO/Selector.swift b/Sources/NIO/Selector.swift index 06a192a11..f2c224f72 100644 --- a/Sources/NIO/Selector.swift +++ b/Sources/NIO/Selector.swift @@ -398,11 +398,11 @@ final class Selector { break case EVFILT_READ: if let registration = registrations[Int(ev.ident)] { - try body((SelectorEvent(readable: true, writable: false, registration: registration))) + try body((SelectorEvent(io: .read, registration: registration))) } case EVFILT_WRITE: if let registration = registrations[Int(ev.ident)] { - try body((SelectorEvent(readable: false, writable: true, registration: registration))) + try body((SelectorEvent(io: .write, registration: registration))) } default: // We only use EVFILT_USER, EVFILT_READ and EVFILT_WRITE. @@ -466,6 +466,16 @@ struct SelectorEvent { public let registration: R public let io: IOEvent + /// Create new instance + /// + /// - parameters: + /// - io: The `IOEvent` that triggered this event. + /// - registration: The registration that belongs to the event. + init(io: IOEvent, registration: R) { + self.io = io + self.registration = registration + } + /// Create new instance /// /// - parameters: @@ -474,11 +484,11 @@ struct SelectorEvent { /// - registration: The registration that belongs to the event. init(readable: Bool, writable: Bool, registration: R) { if readable { - io = writable ? .all : .read + self.io = writable ? .all : .read } else if writable { - io = .write + self.io = .write } else { - io = .none + self.io = .none } self.registration = registration }