15 Commits
Author SHA1 Message Date
Cameron Robey 6d2afc1728 Remove non-copyable types to fix crash with exclusivity checking disabled (#300)
Workaround a compiler issue in Swift 6.1 with non-copyable types and
exclusivity checking.

### Motivation:

Code introduced in #298, led to a runtime crash when compiling with
`-Xswiftc -enforce-exclusivity=unchecked`. This fixes the issue by
removing non-copyable types from the implementation, whilst retaining a
fix for copy-on-write behaviour.

### Modifications:

- Change LifecycleStateMachine to not use non-copyable types
- Use a `.modifying` state instead to prevent copy-on-write

### Result:

No runtime crash when compiling with exclusivity checks disabled on
swift 6.1, behaviour otherwise unchanged, apart from possible
performance loss from not using non-copyable types.
2025-12-09 09:07:52 +00:00
Cameron Robey a46134557b Fix copy on write behaviour in QuiescingHelper (#298)
Fix a copy on write issue in QuiescingHelper that led to significant
performance problems when the number of channels became large, or
connection churn.

### Motivation:

When using QuiescingHelper, every channel holds onto a reference to
ChannelCollector, which leads to copy on write behaviour for
`openChannels[]`. This has performance issues when a large number of
channels are open (e.g. 25k channels can be hundreds of KB), and every
time a channel is opened, or closed this is copied. As accepting
channels happens on a single NIO thread, this work is all done on that
thread, and can lead to saturation, and no more channels being accepted.

### Modifications:

Move the state into a non copyable LifecycleStateMachine, to avoid the
copies.

### Result:

Overhead from ChannelCollector disappears (as seen in traces from
http://github.com/apple/swift-profile-recorder).
2025-12-04 11:06:22 +00:00
George Barnett 20c59b2d64 Strict concurrency for NIOExtras and NIOExtrasTests (#254) 2025-03-31 11:53:06 +01:00
Rick Newton-Rogers 3f776e9aaf Migrate CI to use GitHub Actions. (#234)
### Motivation:

To migrate to GitHub actions and centralised infrastructure.

### Modifications:

Changes of note:
* Adopt swift-format using rules from SwiftNIO
* Remove scripts and docker files which are no longer needed

### Result:

Feature parity with old CI.
2024-10-28 14:00:57 +00:00
Franz Busch d75ed708d0 Refactor QuiescingHelper to exhaustively iterate state (#193)
# Motivation
Currently the `QuiescingHelper` is crashing on a precondition if you call shutdown when it already was shutdown. However, that can totally happen and we should support it.

# Modification
Refactor the `QuiescingHelper` to exhaustively switch over its state in every method. Furthermore, I added a few more test cases to test realistic scenarios.

# Result
We are now reliable checking our state and making sure to allow most transitions.
2023-02-24 09:24:37 -08:00
carolinacass 6bd9bf5c29 ServerQuiescingHelper no longer leaking promises (#192)
* ServerQuiescingHelper no longer leaking promises

Motivation:
ServerQuiescingHelper leaked promises when promise left scope and not succeeded

Modifications:
Failing promise within a deinit

* Minor fixes

* generating linux tests

* mini update
2023-02-13 11:45:10 +00:00
David Nadoba d373eaf7db Replace NIOSendable with Sendable (#181) 2022-10-13 07:43:15 -07:00
David Nadoba 985a485f71 Remove #if compiler(>=5.5) (#182) 2022-10-13 14:04:27 +01:00
Peter AdamsandCory Benfield da7c04777b Docnioextras (#169)
* Improve documentation for NIOExtras

Motivation:

Docs will help users do things correctly.

Modifications:

Add missing comments, improve links.

Result:

Better docc documentation

* Docc in NIOHTTPCompression

* NIOSOCKS docc

* Correct bad symbol

* Minor typo

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-08-03 01:34:45 -07:00
David Evans e4dc3c8d1d Implement Sendable (#160)
Make every non-channel class conform to Sendable (or @unchecked Sendable) to prepare for NIO.
2022-05-04 11:46:21 +01:00
Cory Benfield d66ae0557e Clean up imports and dependencies. (#144)
Motivation:

With NIO 2.32.0 we broke the core NIO module up into modules that split
apart the POSIX layer and the core abstractions. As a result, this
package no longer needs to express a hard dependency on the POSIX layer.

Modifications:

- Rewrote imports of NIO to NIOCore.
- Added NIOEmbedded and NIOPosix imports where necessary in tests.
- Extended soundness script to detect NIO imports.
- Note that the main modules still depend on NIO, which is necessary
    for backwards-compatibility reasons. This dependency is unused.

Result:

No need to use NIOPosix.
2021-09-14 16:30:39 +01:00
Fabian FettandCory Benfield caa96cd4de Use eventLoop.assertInEventLoop() over assert(eventLoop.inEventLoop) (#111)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2021-01-22 09:04:46 +00:00
Johannes Weiss 5a2fc66068 ServerQuiescingHelper: don't swallow close errors (#54)
Motivation:

ServerQuiescingHelper used to swallow close errors and it shoulnd't do
that.

Modifications:

Don't swallow close errors.

Result:

More correctness.
2019-08-07 18:05:47 +01:00
Johannes Weiss 7b7fcf09be port to NIO 2 (#24)
Motivation:

NIO 2 is the new hot stuff.

Modifications:

port to NIO 2

Result:

newer, shinier
2019-02-26 13:01:48 +00:00
Johannes Weiß 4b14b7f2b1 quiescing helper & demo (#2)
Motivation:

In a few cases quiescing a server application is useful but it's harder
than necessary with core-NIO. Therefore this adds a helper & a
demonstration.

Modifications:

- add `QuiescingHelper` which helps users to quiesce a channel by
  collecting all accepted channels and when needed sends them the
  quiescing user event. When all collected channels have closed the
  user will be notified and can just shut down the ELG.
- added a demo implementation with a simple HTTP server that quiesces
  when receiving a signal

Result:

Make it quite easy to quiesce a server and show users how to do it.
2018-05-17 20:27:15 +02:00