Skip to content

Commit

Permalink
Add strict concurrency to NIOUDPEchoServer (#3101)
Browse files Browse the repository at this point in the history
Motivation:

Another strict concurrency change, another echo handler.

Modifications:

Move to sync operations.

Result:

Another step on strict concurrency.
  • Loading branch information
Lukasa authored Feb 3, 2025
1 parent 8bf3316 commit d273f90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ let package = Package(
"NIOPosix",
"NIOCore",
],
exclude: ["README.md"]
exclude: ["README.md"],
swiftSettings: strictConcurrencySettings
),
.executableTarget(
name: "NIOUDPEchoClient",
Expand Down
5 changes: 3 additions & 2 deletions Sources/NIOUDPEchoServer/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ var bootstrap = DatagramBootstrap(group: group)

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

defer {
Expand Down

0 comments on commit d273f90

Please sign in to comment.