Skip to content

Commit d273f90

Browse files
authored
Add strict concurrency to NIOUDPEchoServer (#3101)
Motivation: Another strict concurrency change, another echo handler. Modifications: Move to sync operations. Result: Another step on strict concurrency.
1 parent 8bf3316 commit d273f90

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ let package = Package(
375375
"NIOPosix",
376376
"NIOCore",
377377
],
378-
exclude: ["README.md"]
378+
exclude: ["README.md"],
379+
swiftSettings: strictConcurrencySettings
379380
),
380381
.executableTarget(
381382
name: "NIOUDPEchoClient",

Sources/NIOUDPEchoServer/main.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ var bootstrap = DatagramBootstrap(group: group)
4747

4848
// Set the handlers that are applied to the bound channel
4949
.channelInitializer { channel in
50-
// Ensure we don't read faster than we can write by adding the BackPressureHandler into the pipeline.
51-
channel.pipeline.addHandler(EchoHandler())
50+
channel.eventLoop.makeCompletedFuture {
51+
try channel.pipeline.syncOperations.addHandler(EchoHandler())
52+
}
5253
}
5354

5455
defer {

0 commit comments

Comments
 (0)