mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
GetaddrinfoResolver: don't block EventLoops (#1887)
Motivation: GetaddrinfoResolver is blocking the calling thread for anything that uses a `ClientBootstrap`. Often, `ClientBootstrap`s are used on EventLoops which obviously creates a problem because you mustn't block EventLoops. Modifications: - Offload the `getaddrinfo` call to a `DispatchQueue`. - Keep the semantics: * only do one concurrent `getaddrinfo` call per SelectableEventLoop * prevent thread explosion on `SelectableEventLoop` Result: Less EL blocking. Co-authored-by: George Barnett <gbarnett@apple.com> Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
2 files changed
+34
-8
No files matched your search
@@ -365,6 +365,8 @@ public enum SocketAddress: CustomStringConvertible {
|
||||
|
||||
/// Creates a new `SocketAddress` for the given host (which will be resolved) and port.
|
||||
///
|
||||
/// - warning: This is a blocking call, so please avoid calling this from an `EventLoop`.
|
||||
///
|
||||
/// - parameters:
|
||||
/// - host: the hostname which should be resolved.
|
||||
/// - port: the port itself
|
||||
|
||||
Reference in new issue
Block a user