Skip to content

Commit 8bf3316

Browse files
Lukasaglbrntt
andauthored
Clean up concurrency in NIOEchoClient (apple#3099)
Motivation: We're getting to the examples now! This patch updates NIOEchoClient to be clean under strict concurrency. Modifications: Use the sync operations to add echo handler. Result: Another strict concurrency module. Co-authored-by: George Barnett <gbarnett@apple.com>
1 parent a849d50 commit 8bf3316

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Package.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ let package = Package(
301301
"NIOCore",
302302
"NIOConcurrencyHelpers",
303303
],
304-
exclude: ["README.md"]
304+
exclude: ["README.md"],
305+
swiftSettings: strictConcurrencySettings
305306
),
306307
.executableTarget(
307308
name: "NIOHTTP1Server",

Sources/NIOEchoClient/main.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ let bootstrap = ClientBootstrap(group: group)
5858
// Enable SO_REUSEADDR.
5959
.channelOption(.socketOption(.so_reuseaddr), value: 1)
6060
.channelInitializer { channel in
61-
channel.pipeline.addHandler(EchoHandler())
61+
channel.eventLoop.makeCompletedFuture {
62+
try channel.pipeline.syncOperations.addHandler(EchoHandler())
63+
}
6264
}
6365
defer {
6466
try! group.syncShutdownGracefully()

0 commit comments

Comments
 (0)