From 49c787c26920be7af9881ed9500d56314e965406 Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Thu, 21 Sep 2023 20:57:46 +0100 Subject: [PATCH 1/6] Update Bootstrap.swift --- Sources/NIOPosix/Bootstrap.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/NIOPosix/Bootstrap.swift b/Sources/NIOPosix/Bootstrap.swift index 0e90bb85d6..f512ce8f27 100644 --- a/Sources/NIOPosix/Bootstrap.swift +++ b/Sources/NIOPosix/Bootstrap.swift @@ -712,9 +712,14 @@ private extension Channel { /// A `ClientBootstrap` is an easy way to bootstrap a `SocketChannel` when creating network clients. /// -/// Usually you re-use a `ClientBootstrap` once you set it up and called `connect` multiple times on it. +/// You may re-use a `ClientBootstrap` once you set it up and called `connect` multiple times on it. /// This way you ensure that the same `EventLoop`s will be shared across all your connections. /// +/// Keep in mind that `ClientBoostrap` is not `Sendable` so you cannot share the same instance across +/// multiple threads/`EventLoop`s. Creating a `ClientBootstrap` is cheap so instead of arranging +/// synchronization to re-use a single `ClientBootstrap` instance across threads, it's advisable to +/// just create fresh instances. +/// /// Example: /// /// ```swift @@ -731,7 +736,7 @@ private extension Channel { /// // resolves to both IPv4 and IPv6 addresses, cf. Happy Eyeballs). /// channel.pipeline.addHandler(MyChannelHandler()) /// } -/// try! bootstrap.connect(host: "example.org", port: 12345).wait() +/// try bootstrap.connect(host: "example.org", port: 12345).wait() /// /* the Channel is now connected */ /// ``` /// From d8606bf56f648b9eab12db5c4b04b418ca545457 Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Thu, 21 Sep 2023 21:00:33 +0100 Subject: [PATCH 2/6] Update Bootstrap.swift --- Sources/NIOPosix/Bootstrap.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NIOPosix/Bootstrap.swift b/Sources/NIOPosix/Bootstrap.swift index f512ce8f27..f8b952af06 100644 --- a/Sources/NIOPosix/Bootstrap.swift +++ b/Sources/NIOPosix/Bootstrap.swift @@ -718,7 +718,7 @@ private extension Channel { /// Keep in mind that `ClientBoostrap` is not `Sendable` so you cannot share the same instance across /// multiple threads/`EventLoop`s. Creating a `ClientBootstrap` is cheap so instead of arranging /// synchronization to re-use a single `ClientBootstrap` instance across threads, it's advisable to -/// just create fresh instances. +/// create fresh instances. /// /// Example: /// From 82e4136319bc06c03ca41e27e3c64ff21b0eecd1 Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Fri, 22 Sep 2023 15:21:24 +0100 Subject: [PATCH 3/6] Update Sources/NIOPosix/Bootstrap.swift --- Sources/NIOPosix/Bootstrap.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NIOPosix/Bootstrap.swift b/Sources/NIOPosix/Bootstrap.swift index f8b952af06..8d7ed24605 100644 --- a/Sources/NIOPosix/Bootstrap.swift +++ b/Sources/NIOPosix/Bootstrap.swift @@ -712,7 +712,7 @@ private extension Channel { /// A `ClientBootstrap` is an easy way to bootstrap a `SocketChannel` when creating network clients. /// -/// You may re-use a `ClientBootstrap` once you set it up and called `connect` multiple times on it. +/// You may re-use a `ClientBootstrap` once you set it up and call `connect` multiple times on it. /// This way you ensure that the same `EventLoop`s will be shared across all your connections. /// /// Keep in mind that `ClientBoostrap` is not `Sendable` so you cannot share the same instance across From bee7ad9078da03fddca74fc3f1c38bc48211c39b Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Fri, 22 Sep 2023 15:21:30 +0100 Subject: [PATCH 4/6] Update Sources/NIOPosix/Bootstrap.swift --- Sources/NIOPosix/Bootstrap.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NIOPosix/Bootstrap.swift b/Sources/NIOPosix/Bootstrap.swift index 8d7ed24605..3af578698b 100644 --- a/Sources/NIOPosix/Bootstrap.swift +++ b/Sources/NIOPosix/Bootstrap.swift @@ -713,7 +713,7 @@ private extension Channel { /// A `ClientBootstrap` is an easy way to bootstrap a `SocketChannel` when creating network clients. /// /// You may re-use a `ClientBootstrap` once you set it up and call `connect` multiple times on it. -/// This way you ensure that the same `EventLoop`s will be shared across all your connections. +/// This ensures all connections you create share the same ``EventLoop``. /// /// Keep in mind that `ClientBoostrap` is not `Sendable` so you cannot share the same instance across /// multiple threads/`EventLoop`s. Creating a `ClientBootstrap` is cheap so instead of arranging From becd298f6cfa5eaa333993dd821e815f574ea24d Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Fri, 22 Sep 2023 15:21:38 +0100 Subject: [PATCH 5/6] Update Sources/NIOPosix/Bootstrap.swift --- Sources/NIOPosix/Bootstrap.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/NIOPosix/Bootstrap.swift b/Sources/NIOPosix/Bootstrap.swift index 3af578698b..2d95249b8c 100644 --- a/Sources/NIOPosix/Bootstrap.swift +++ b/Sources/NIOPosix/Bootstrap.swift @@ -715,7 +715,11 @@ private extension Channel { /// You may re-use a `ClientBootstrap` once you set it up and call `connect` multiple times on it. /// This ensures all connections you create share the same ``EventLoop``. /// -/// Keep in mind that `ClientBoostrap` is not `Sendable` so you cannot share the same instance across +/// Keep in mind that `ClientBoostrap` is not ``Sendable``, so you cannot share the same +/// instance across multiple ``EventLoop``s or multiple concurrency domains in general. +/// Creating a `ClientBootstrap` is cheap. So instead of arranging synchronization allowing +/// concurrent code to re-use a single `ClientBootstrap` instance across many tasks, it is often +/// easier to create a dedicated instance for each task. /// multiple threads/`EventLoop`s. Creating a `ClientBootstrap` is cheap so instead of arranging /// synchronization to re-use a single `ClientBootstrap` instance across threads, it's advisable to /// create fresh instances. From d83cc39680711ce65f2803e65b9efd1a4ee298eb Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Fri, 22 Sep 2023 15:41:30 +0100 Subject: [PATCH 6/6] Update Bootstrap.swift @tayloraswift I needed to undo the ``Sendable`` and ``EventLoop`` because they're in different modules :| --- Sources/NIOPosix/Bootstrap.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/NIOPosix/Bootstrap.swift b/Sources/NIOPosix/Bootstrap.swift index 2d95249b8c..6e92f1c157 100644 --- a/Sources/NIOPosix/Bootstrap.swift +++ b/Sources/NIOPosix/Bootstrap.swift @@ -713,10 +713,10 @@ private extension Channel { /// A `ClientBootstrap` is an easy way to bootstrap a `SocketChannel` when creating network clients. /// /// You may re-use a `ClientBootstrap` once you set it up and call `connect` multiple times on it. -/// This ensures all connections you create share the same ``EventLoop``. +/// This ensures all connections you create share the same `EventLoop`. /// -/// Keep in mind that `ClientBoostrap` is not ``Sendable``, so you cannot share the same -/// instance across multiple ``EventLoop``s or multiple concurrency domains in general. +/// Keep in mind that `ClientBoostrap` is not `Sendable`, so you cannot share the same +/// instance across multiple `EventLoop`s or multiple concurrency domains in general. /// Creating a `ClientBootstrap` is cheap. So instead of arranging synchronization allowing /// concurrent code to re-use a single `ClientBootstrap` instance across many tasks, it is often /// easier to create a dedicated instance for each task.