Skip to content

Commit

Permalink
PR changes requested
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Oct 6, 2023
1 parent 2d87051 commit 887e8a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
22 changes: 2 additions & 20 deletions Sources/Hummingbird/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,8 @@ public final class HBApplication: HBExtensible {
/// Version of `run` that can be called from asynchronous context
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
public func asyncRun() async throws {
try await self.onExecutionQueue { app in
try app.start()
app.wait()
}
try self.start()
await self.asyncWait()
}

/// Start application
Expand Down Expand Up @@ -254,22 +252,6 @@ public final class HBApplication: HBExtensible {
}
}

/// Run throwing closure on private execution queue
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private func onExecutionQueue(_ process: @Sendable @escaping (HBApplication) throws -> Void) async throws {
let unsafeApp = HBUnsafeTransfer(self)
try await withCheckedThrowingContinuation { continuation in
HBApplication.executionQueue.async {
do {
try process(unsafeApp.wrappedValue)
continuation.resume()
} catch {
continuation.resume(throwing: error)
}
}
}
}

/// Run closure on private execution queue
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
private func onExecutionQueue(_ process: @Sendable @escaping (HBApplication) -> Void) async {
Expand Down
6 changes: 2 additions & 4 deletions Sources/PerformanceTest/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import NIOPosix

// get environment
let hostname = HBEnvironment.shared.get("SERVER_HOSTNAME") ?? "127.0.0.1"
let port = HBEnvironment.shared.get("SERVER_PORT", as: Int.self) ?? 8080
let port = HBEnvironment.shared.get("SERVER_PORT", as: Int.self) ?? 8081

// create app
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 2)
Expand Down Expand Up @@ -54,6 +54,4 @@ app.router.get("json") { _ in
}

// run app
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) {
try await app.asyncRun()
}
try app.run()

0 comments on commit 887e8a8

Please sign in to comment.