Skip to content

Commit

Permalink
trimmed whitespace (#361)
Browse files Browse the repository at this point in the history
Trimmed trailing whitespace.

Motivation:

Trimmed trailing whitespace.

Modifications:

Trimmed trailing whitespace.

Result:

Less trailing whitespace.
  • Loading branch information
adamnemecek authored and normanmaurer committed Apr 27, 2018
1 parent 6565ec5 commit 776c3f4
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 142 deletions.
14 changes: 7 additions & 7 deletions Sources/NIO/ChannelHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import struct Dispatch.DispatchTime
public final class AcceptBackoffHandler: ChannelDuplexHandler {
public typealias InboundIn = Channel
public typealias OutboundIn = Channel

private var nextReadDeadlineNS: Int?
private let backoffProvider: (IOError) -> TimeAmount?
private var scheduledRead: Scheduled<Void>?
Expand All @@ -40,7 +40,7 @@ public final class AcceptBackoffHandler: ChannelDuplexHandler {
public init(backoffProvider: @escaping (IOError) -> TimeAmount? = AcceptBackoffHandler.defaultBackoffProvider) {
self.backoffProvider = backoffProvider
}

public func read(ctx: ChannelHandlerContext) {
// If we already have a read scheduled there is no need to schedule another one.
guard scheduledRead == nil else { return }
Expand All @@ -58,7 +58,7 @@ public final class AcceptBackoffHandler: ChannelDuplexHandler {
ctx.read()
}
}

public func errorCaught(ctx: ChannelHandlerContext, error: Error) {
if let ioError = error as? IOError {
if let amount = backoffProvider(ioError) {
Expand All @@ -71,7 +71,7 @@ public final class AcceptBackoffHandler: ChannelDuplexHandler {
}
ctx.fireErrorCaught(error)
}

public func channelInactive(ctx: ChannelHandlerContext) {
if let scheduled = self.scheduledRead {
scheduled.cancel()
Expand All @@ -80,7 +80,7 @@ public final class AcceptBackoffHandler: ChannelDuplexHandler {
self.nextReadDeadlineNS = nil
ctx.fireChannelInactive()
}

public func handlerRemoved(ctx: ChannelHandlerContext) {
if let scheduled = self.scheduledRead {
// Cancel the previous scheduled read and trigger a read directly. This is needed as otherwise we may never read again.
Expand All @@ -90,13 +90,13 @@ public final class AcceptBackoffHandler: ChannelDuplexHandler {
}
self.nextReadDeadlineNS = nil
}

private func scheduleRead(in: TimeAmount, ctx: ChannelHandlerContext) {
self.scheduledRead = ctx.eventLoop.scheduleTask(in: `in`) {
self.doRead(ctx)
}
}

private func doRead(_ ctx: ChannelHandlerContext) {
/// Reset the backoff time and read.
self.nextReadDeadlineNS = nil
Expand Down
6 changes: 3 additions & 3 deletions Sources/NIO/EventLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ extension TimeAmount: Comparable {
public static func < (lhs: TimeAmount, rhs: TimeAmount) -> Bool {
return lhs.nanoseconds < rhs.nanoseconds
}

public static func == (lhs: TimeAmount, rhs: TimeAmount) -> Bool {
return lhs.nanoseconds == rhs.nanoseconds
}
Expand Down Expand Up @@ -644,7 +644,7 @@ typealias ThreadInitializer = (Thread) -> Void
final public class MultiThreadedEventLoopGroup: EventLoopGroup {

private static let threadSpecificEventLoop = ThreadSpecificVariable<SelectableEventLoop>()

private let index = Atomic<Int>(value: 0)
private let eventLoops: [SelectableEventLoop]

Expand Down Expand Up @@ -785,7 +785,7 @@ extension ScheduledTask: Comparable {
public static func < (lhs: ScheduledTask, rhs: ScheduledTask) -> Bool {
return lhs.readyTime < rhs.readyTime
}

public static func == (lhs: ScheduledTask, rhs: ScheduledTask) -> Bool {
return lhs === rhs
}
Expand Down
18 changes: 9 additions & 9 deletions Sources/NIO/EventLoopFuture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ extension EventLoopFuture {
let promise = EventLoopPromise<(T,U)>(eventLoop: eventLoop, file: file, line: line)
var tvalue: T?
var uvalue: U?

assert(self.eventLoop === promise.futureResult.eventLoop)
_whenComplete { () -> CallbackList in
switch self.value! {
Expand All @@ -702,7 +702,7 @@ extension EventLoopFuture {
}
return CallbackList()
}

let hopOver = other.hopTo(eventLoop: self.eventLoop)
hopOver._whenComplete { () -> CallbackList in
assert(self.eventLoop.inEventLoop)
Expand All @@ -718,7 +718,7 @@ extension EventLoopFuture {
}
return CallbackList()
}

return promise.futureResult
}

Expand Down Expand Up @@ -862,7 +862,7 @@ extension EventLoopFuture {
let body = EventLoopFuture<Void>.reduce((), futures, eventLoop: eventLoop) { (_: (), _: ()) in }
return body
}

/// Returns a new `EventLoopFuture` that fires only when all the provided futures complete.
/// The new `EventLoopFuture` contains the result of reducing the `initialResult` with the
/// values of the `[EventLoopFuture<U>]`.
Expand All @@ -884,14 +884,14 @@ extension EventLoopFuture {
/// - returns: A new `EventLoopFuture` with the reduced value.
public static func reduce<U>(_ initialResult: T, _ futures: [EventLoopFuture<U>], eventLoop: EventLoop, _ nextPartialResult: @escaping (T, U) -> T) -> EventLoopFuture<T> {
let f0 = eventLoop.newSucceededFuture(result: initialResult)

let body = f0.fold(futures) { (t: T, u: U) -> EventLoopFuture<T> in
eventLoop.newSucceededFuture(result: nextPartialResult(t, u))
}

return body
}

/// Returns a new `EventLoopFuture` that fires only when all the provided futures complete.
/// The new `EventLoopFuture` contains the result of combining the `initialResult` with the
/// values of the `[EventLoopFuture<U>]`. This funciton is analogous to the standard library's
Expand All @@ -912,14 +912,14 @@ extension EventLoopFuture {
public static func reduce<U>(into initialResult: T, _ futures: [EventLoopFuture<U>], eventLoop: EventLoop, _ updateAccumulatingResult: @escaping (inout T, U) -> Void) -> EventLoopFuture<T> {
let p0: EventLoopPromise<T> = eventLoop.newPromise()
var result: T = initialResult

let f0 = eventLoop.newSucceededFuture(result: ())
let future = f0.fold(futures) { (_: (), value: U) -> EventLoopFuture<Void> in
assert(eventLoop.inEventLoop)
updateAccumulatingResult(&result, value)
return eventLoop.newSucceededFuture(result: ())
}

future.whenSuccess {
assert(eventLoop.inEventLoop)
p0.succeed(result: result)
Expand Down
26 changes: 13 additions & 13 deletions Sources/NIO/IntegerTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
@_versioned
struct _UInt24: ExpressibleByIntegerLiteral {
typealias IntegerLiteralType = UInt16

@_versioned var b12: UInt16
@_versioned var b3: UInt8

private init(b12: UInt16, b3: UInt8) {
self.b12 = b12
self.b3 = b3
}

init(integerLiteral value: UInt16) {
self.init(b12: value, b3: 0)
}

static let bitWidth: Int = 24

static var max: _UInt24 {
return .init(b12: .max, b3: .max)
}

static let min: _UInt24 = 0
}

Expand Down Expand Up @@ -77,27 +77,27 @@ extension _UInt24: Equatable {
/// A 56-bit unsigned integer value type.
struct _UInt56: ExpressibleByIntegerLiteral {
typealias IntegerLiteralType = UInt32

@_versioned var b1234: UInt32
@_versioned var b56: UInt16
@_versioned var b7: UInt8

private init(b1234: UInt32, b56: UInt16, b7: UInt8) {
self.b1234 = b1234
self.b56 = b56
self.b7 = b7
}

init(integerLiteral value: UInt32) {
self.init(b1234: value, b56: 0, b7: 0)
}

static let bitWidth: Int = 56

static var max: _UInt56 {
return .init(b1234: .max, b56: .max, b7: .max)
}

static let min: _UInt56 = 0
}

Expand All @@ -108,7 +108,7 @@ extension _UInt56 {
b56: UInt16(truncatingIfNeeded: (value & 0xff_ff_00_00_00_00) >> 32),
b7: UInt8( value >> 48))
}

init(_ value: Int) {
self.init(UInt64(value))
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/NIO/SocketChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ final class ServerSocketChannel: BaseSocketChannel<ServerSocket> {
}
return result
}

override func shouldCloseOnReadError(_ err: Error) -> Bool {
guard let err = err as? IOError else { return true }

switch err.errnoCode {
case ECONNABORTED,
EMFILE,
Expand Down
8 changes: 4 additions & 4 deletions Sources/NIOHTTP1/HTTPServerPipelineHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public final class HTTPServerPipelineHandler: ChannelDuplexHandler {
private enum BufferedEvent {
/// A channelRead event.
case channelRead(NIOAny)

case error(HTTPParserError)

/// A TCP half-close. This is buffered to ensure that subsequent channel
Expand All @@ -139,12 +139,12 @@ public final class HTTPServerPipelineHandler: ChannelDuplexHandler {
/// don't pipeline, so this initially allocates no space for data at all. Clients that
/// do pipeline will cause dynamic resizing of the buffer, which is generally acceptable.
private var eventBuffer = CircularBuffer<BufferedEvent>(initialRingCapacity: 0)

enum NextExpectedMessageType {
case head
case bodyOrEnd
}

// always `nil` in release builds, never `nil` in debug builds
private var nextExpectedInboundMessage: NextExpectedMessageType?
// always `nil` in release builds, never `nil` in debug builds
Expand Down Expand Up @@ -196,7 +196,7 @@ public final class HTTPServerPipelineHandler: ChannelDuplexHandler {
ctx.fireUserInboundEventTriggered(event)
}
}

public func errorCaught(ctx: ChannelHandlerContext, error: Error) {
guard let httpError = error as? HTTPParserError else {
ctx.fireErrorCaught(error)
Expand Down
12 changes: 6 additions & 6 deletions Sources/NIOHTTP1/HTTPTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public struct HTTPRequestHead: Equatable {
return String(uri: rawURI)
}
set {
rawURI = .string(newValue)
rawURI = .string(newValue)
}
}

Expand Down Expand Up @@ -508,7 +508,7 @@ public struct HTTPHeaders: CustomStringConvertible {
}
return false
}

@available(*, deprecated, message: "getCanonicalForm has been changed to a subscript: headers[canonicalForm: name]")
public func getCanonicalForm(_ name: String) -> [String] {
return self[canonicalForm: name]
Expand Down Expand Up @@ -563,7 +563,7 @@ internal extension ByteBuffer {
}
extension HTTPHeaders: Sequence {
public typealias Element = (name: String, value: String)

/// An iterator of HTTP header fields.
///
/// This iterator will return each value for a given header name separately. That
Expand All @@ -578,7 +578,7 @@ extension HTTPHeaders: Sequence {
public mutating func next() -> Element? {
return headerParts.next()
}
}
}

public func makeIterator() -> Iterator {
return Iterator(headerParts: headers.map { (self.string(idx: $0.name), self.string(idx: $0.value)) }.makeIterator())
Expand All @@ -593,7 +593,7 @@ public extension _DeprecateHTTPHeaderIterator {
@available(*, deprecated, message: "Please use the HTTPHeaders.Iterator type")
public func makeIterator() -> AnyIterator<Element> {
return AnyIterator(makeIterator() as Iterator)
}
}
}

/* private but tests */ internal extension Character {
Expand Down Expand Up @@ -1232,7 +1232,7 @@ public enum HTTPResponseStatus {
/// Initialize a `HTTPResponseStatus` from a given status and reason.
///
/// - Parameter statusCode: The integer value of the HTTP response status code
/// - Parameter reasonPhrase: The textual reason phrase from the response. This will be
/// - Parameter reasonPhrase: The textual reason phrase from the response. This will be
/// discarded in favor of the default if the `statusCode` matches one that we know.
public init(statusCode: Int, reasonPhrase: String = "") {
switch statusCode {
Expand Down
6 changes: 3 additions & 3 deletions Sources/NIOWebSocketServer/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ switch (arg1, arg1.flatMap(Int.init), arg2.flatMap(Int.init)) {
case (.some(let h), _ , .some(let p)):
/* we got two arguments, let's interpret that as host and port */
bindTarget = .ip(host: h, port: p)

case (let portString?, .none, _):
// Couldn't parse as number, expecting unix domain socket path.
bindTarget = .unixDomainSocket(path: portString)

case (_, let p?, _):
// Only one argument --> port.
bindTarget = .ip(host: defaultHost, port: p)

default:
bindTarget = .ip(host: defaultHost, port: defaultPort)
}
Expand Down
Loading

0 comments on commit 776c3f4

Please sign in to comment.