Commit Graph
2949 Commits
Author SHA1 Message Date
Cory Benfield f43b37eb31 Make the FileSystem world strict concurrency clean (#3107)
Motivation:

We have a few other file system modules with a small amount of code, and
a lot of tests. Most of these require no changes for strict concurrency,
so let's tackle them all.

Modifications:

Strict concurrency for filesystem targets enabled. Fixed a few incorrect
test case captures.

Result:

Strict concurrency clean filesystem bits.
2025-02-04 11:01:48 +00:00
Tim CondonandCory Benfield ac79370dee Add ChannelPipeline.SynchronousOperations.Position (#3065)
Adds a new `ChannelPipeline.SynchronousOperations.Position` type to fill
a hole in the API that prevented non-sendable Channel handlers being
added at a position to the pipeline via the synchronous operations.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-02-04 10:31:29 +00:00
Cory Benfield 08b3b4f95e Make _NIOFileSystem strict concurrency compatible (#3098)
Motivation:

We're continuing out Strict Concurrency journey, making sure users of
NIO can write data-race-free code.

Modifications:

- Added some missing Sendable annotations in NIOAsyncSequenceProducer
- Made BufferedStream unconditionally Sendable, and required its Element
type to also be Sendable.

    The prior constraint wasn't actually correct. We always
    behaved as though the element types were Sendable, by passing
    them into continuations. This cleans things up.
- Made AnyAsyncSequence Sendable, which it needs to be.
- Made BufferedOrAnyStream Sendable, which it needs to be.
- Made DirectoryEntries explicitly Sendable, which it was.
- Made DirectoryEntries.Batched explicitly Sendable.

Result:

Better concurrency-safety
2025-02-03 17:56:57 +00:00
Cory Benfield 2f1c7800e4 Strict concurrency for NIOTests (#3106)
Motivation:

NIOTests was already warning free, now we're just going to make sure of
it.

Modifications:

Enable strict concurrency for NIOTests

Result:

Our relentless safety march continues.
2025-02-03 16:57:45 +00:00
Cory Benfield e2bfa2fc75 Strict concurrency enablement for some test targets (#3105)
Motivation:

A few more low-hanging-fruit test targets.

Modifications:

Enable strict concurrency for:

- NIOFoundationCompatTests
- NIOSingletonsTests

Result:

We're knocking down those targets, one by one.
2025-02-03 16:32:55 +00:00
Cory BenfieldandRick Newton-Rogers 8f19d80751 Strict concurrency for the chat examples (#3104)
Motivation:

Our next suite of examples for strict concurrency are the chat ones.
These are very similar to the rest: either no violation at all, or just
a need to use the sync operations on pipeline setup.

Modifications:

- Use sync operations
- Lock in strict concurrency checking

Result:

We continue our march.

Co-authored-by: Rick Newton-Rogers <rnro@apple.com>
2025-02-03 16:04:40 +00:00
Cory Benfield 0bc48ebbc5 Strict concurrency for TCP examples (#3103)
Motivation:

Two more examples with no changes required.

Modifications:

Lock in strict concurrency for NIOTCPEchoClient and NIOTCPEchoServer.

Result:

Even more stricter concurrencier.
2025-02-03 15:20:45 +00:00
Cory Benfield 9a181b3aae Update NIOUDPEchoClient for strict concurrency (#3102)
Motivation:

NIOUDPEchoClient should be strict concurrency clean.

Modifications:

Annotate one closure @Sendable to convince Swift it's ok.

Result:

Strict concurrency clean in NIOUDPEchoClient.
2025-02-03 14:22:56 +00:00
Cory Benfield aa360ab8e8 Lock in strict concurrency in NIOEchoServer (#3100)
Motivation:

Prior patches actually removed all the issues in NIOEchoServer, so let's
bank the win.

Modifications:

Added strict concurrency checking to NIOEchoServer

Result:

More stricter.
2025-02-03 13:55:41 +00:00
Cory Benfield d273f906fe 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.
2025-02-03 12:56:02 +00:00
Cory BenfieldandGeorge Barnett 8bf3316c37 Clean up concurrency in NIOEchoClient (#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>
2025-02-03 11:49:56 +00:00
Cory Benfield a849d50ce6 Opt NIO module into Strict Concurrency (#3097)
Motivation:

Honestly these little modules are pretty mechanical now.

Modifications:

Add the strict concurrency flags to a module with nothing in it.

Result:

Become even more automatic from way downtown.
2025-02-03 11:25:02 +00:00
Cory Benfield 29c920d3e6 Opt NIOFoundationCompat into strict concurrency (#3096)
Motivation:

I continue to grab the low-hanging fruit. This time I've opted a purely
data-processing module into strict concurrency. Truly, I am the hero
Gotham deserves.

Modifications:

Set some build flags.

Result:

Stricter concurrency.
2025-02-03 10:51:09 +00:00
Cory Benfield 4ea59742f0 Opt _NIOConcurrency into Strict Concurrency (#3095)
Motivation:

We intend to have this package be completely strict-concurrency clean,
so every target needs to be opted in, even those that currently have no
code.

Modifications:

Opt in this empty target to strict concurrency.

Result:

One more database entry.
2025-02-03 10:22:07 +00:00
Rick Newton-Rogers 577e893f7e Update the legacy CI matrix for 6.1 nightly (#3094)
### Motivation:

Some repositories still use the older CI Swift matrix directly so we
need to update it to handle 6.1 nightlies.

### Modifications:

Replace 6.0 nightly with 6.1 nightly.

### Result:

External CI should use 6.1 nightly.
2025-01-31 13:17:51 +00:00
Johannes Weiss dff45738d8 undo Xcode 13 GM workaround (#3092)
### Motivation:

Xcode 13 is really quite old (3 major releases and it was the GM release
anyway) and this workaround can cause other issues.

### Modifications:

- Remove the Xcode 13 GM workaround.
- 
### Result:

Better, possibly faster code.
2.80.0
2025-01-28 20:38:50 +00:00
1e900b4736 NIOFileSystem: Try ${TMPDIR} first for temporary directory (#3067)
### Motivation:

This PR aligns what temp directory NIOFileSystem will return first:
- First try `${TMPDIR}` as it's an expressed user preference
- On Darwin, try `_CS_DARWIN_USER_TMP_DIR` next. If it's set, return
that.
- Finally, fall back on `/tmp` on Darwin and Linux, and
`/data/local/tmp` on Android.

Closes #2861.

### Modifications:

- Reworks `NIOFileSystem.temporaryDirectory`.

### Result:

- NIOFileSystem will now try `${TMPDIR}` first for the temporary
directory.

### Caveats:

- We might want to align how Swift-NIO and FoundationEssentials resolve
temp directory, and [FoundationEssentials have a different
approach](https://github.com/swiftlang/swift-foundation/blob/9d57f36de757b3d5e3a2f7ffcf27aaec3033509f/Sources/FoundationEssentials/String/String%2BPath.swift#L484-L533).
But, I agree with [this
comment](https://github.com/apple/swift-nio/issues/2861#issuecomment-2327010713),
it feels like TMPDIR is an expected default.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-27 08:45:46 +00:00
Cory Benfield 26d3fb9097 Make NIOPosix strict-concurrency clean (#3090)
Motivation

NIOPosix should be clean under strict concurrency

Modifications

- Fix newly-added issue in GetaddrinfoResolver
- Fix newly-added issue in SEL
- Lock in the win in Package.swift

Result

We did it!
2025-01-27 08:11:08 +00:00
Cory Benfield 85742bc559 Avoid using stderr explicitly (#3089)
Motivation

It's tempting for us to use the FILE * for stderr whenever we want to
print to it. However, the Linux libc modules aren't appropriately
annotated to call that field constant, and indeed it isn't. This causes
Swift to throw a fit if we even touch it.

Modifications

Introduce an awkward function that issues direct writes to stderr
instead of using the FILE *.

Result

Swift is happier.
2025-01-24 16:33:17 +00:00
Cory Benfield c2ccad63e2 Add Sendable annotations to the syscall wrappers (#3087)
Motivation

Unfortunately there are a few places where we have to help the compiler
out to realise that our copies of the libc functions are also Sendable,
and -require-explicit-sendable can cause us some trouble if we don't
annotate our usableFromInline types.

Modifications

Annotate our usableFromInline types
Add some @Sendable

Results

The march continues
2025-01-24 15:10:20 +00:00
Cory Benfield 407e633005 Add simple Sendable conformance to AsyncSequenceFromIterator (#3088)
usableFromInline types need explicit Sendable conformances, so let's add
one here. This type is a trivial wrapper, so let's express that
2025-01-24 14:45:12 +00:00
Cory Benfield ce5d042a33 Remove accidental static var (#3086)
This was never written to, so we don't need it, and it's a Sendable
violation.
2025-01-24 14:10:43 +00:00
Cory Benfield 5a572f587c Add Sendable annotations to SelectorGeneric (#3085)
### Motivation:

Explicit Sendable requires a bunch of annotations in SelectorGeneric, as
many of these types are `@usableFromInline`. This patch applies those.

### Modifications:

- Make many types Sendable
- Make some explicitly not Sendable

### Result:

No missing Sendable warnings
2025-01-24 13:45:24 +00:00
Cory Benfield 5ce7fde1df Strict concurrency for SelectableEventLoop & MTELG (#3084)
Motivation

SelectableEventLoop and MTEL are our major entry points for execution.
These need to be strict concurrency clean. Unfortunately, changes in one
tend to ripple into the other, so we need to tackle both at once.

Modifications

- A few closures get annotated @Sendable
- Add a NIOLockedValueBox to convince the compiler that this use is
safe.
- Make a few types explicitly not Sendable

Result

No concurrency warnings in MTELG and SelectableEventLoop.
2025-01-24 11:42:40 +00:00
Cory Benfield 171a93af3c Sendability clean up for RawSocketBootstrap (#3083)
Motivation

RawSocketBootstrap isn't strict concurrency clean yet, and it should be.

Modifications

Add a few necessary Sendable constraints.

Result

No warnings here boss.
2025-01-24 10:16:10 +00:00
Cory Benfield 6d57d04768 Make NonBlockingFileIO strict-concurrency clean (#3082)
### Motivation:

NonBlockingFileIO is now mostly in a good state, but there are some
missed Sendable annotations. Let's clean that up.

### Modifications:

Mark an inner function as `@Sendable`
Add `Sendable` to `NIODirectoryEntry`.

### Result:

The road continues
2025-01-24 08:49:29 +00:00
Cory Benfield e40cbce38a Clean up Sendability in Thread and ThreadPool (#3081)
Motivation

Next on my journey of discovery is NIOThread and NIOThreadPool. These
are basically fine, but they need some Sendability annotations and a bit
of a cleanup.

Modifications

Add some Sendability
Clean up some shutdown logic to avoid semaphores.

Result

Another step forward to a strict-concurrency safe world.
2025-01-23 15:46:48 +00:00
Cory Benfield 0c547a717c Fix the HappyEyeballsResolver and core Bootstraps under strict concurrency (#3062)
### Motivation:

The HappyEyeballsResolver, being an old part of our stack, has a lot of
code in it that fails to pass strict concurrency checking. That's deeply
suboptimal.

### Modifications:

- Clean up the happy eyeballs resolver under strict concurrency
- Further cleanups to the bootstraps

### Result:

Another step taken on the road to strict concurrency.
2025-01-23 13:22:18 +00:00
Clinton NkwochaandGeorge Barnett b14012bb1a Improve flatScheduleTask (#3079)
Motivation:

As pointed out in #3071, the `flatScheduleTask` implementations can be
improved.

Modifications:

- Refactor the `flatScheduleTask` implementations to skip `flatMap`
calls, which avoids creating an extra promise.
- As there is now a lower number of allocations, reduce the necessary
thresholds for the allocation tests.

Result:

Reduction in the number of allocations in the package.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-22 16:26:51 +00:00
Rick Newton-Rogers 187bfa8863 check-matrix-job.sh should tolerate unset 6.1 vars (#3080)
### Motivation:

We recently added support for nightly 6.1 Swift and old scripts making
use of `check-matrix-job.sh` do not set `COMMAND_OVERRIDE_NIGHTLY_6_1`
which causes the script to fail. We should tolerate this.

### Modifications:

Add a default case for `COMMAND_OVERRIDE_NIGHTLY_6_1`.

### Result:

No failures if a caller doesn't specify `COMMAND_OVERRIDE_NIGHTLY_6_1`.

```
❯ SWIFT_VERSION=nightly-6.1 COMMAND="echo foo" COMMAND_OVERRIDE_5_9="" COMMAND_OVERRIDE_5_10="" COMMAND_OVERRIDE_6_0="" COMMAND_OVERRIDE_NIGHTLY_MAIN="" ./scripts/check-matrix-job.sh
** Running default command
foo
❯ SWIFT_VERSION=nightly-6.1 COMMAND="echo foo" COMMAND_OVERRIDE_5_9="" COMMAND_OVERRIDE_5_10="" COMMAND_OVERRIDE_6_0="" COMMAND_OVERRIDE_NIGHTLY_MAIN="" COMMAND_OVERRIDE_NIGHTLY_6_1="echo bar" ./scripts/check-matrix-job.sh
** Running nightly 6.1 command override
bar
```
2025-01-22 15:24:37 +00:00
Rick Newton-Rogers 9336e1f259 more 6.0 nightly to 6.1 nightly CI changes (#3078)
### Motivation:

Some changes were missed in #3076, passing through parameters for the
new 6.1 version.

### Modifications:

Pass through more parameters, clean up misleading comments.

### Result:

6.1 nightly runs will be more like 6.0 nightly runs were
2025-01-22 13:38:02 +00:00
Rick Newton-Rogers 5595698895 Update nightly CI pipelines to 6.1 instead of 6.0 (#3076)
### Motivation:

Active development has moved to 6.1 so the Swift 6.0 nightlies no longer
deliver much value.

### Modifications:

* Deprecate 6.0 nightly CI configuration parameters
* Introduce new 6.1 nightly CI configuration parameters
* Update the matrix generation script to handle 6.1
 
### Result:

* No more nightly 6.0 CI, 6.1 nightlies are introduced.
* Configuration for 6.0 nightlies no longer has any effect.
* All repos are automatically opted-in to 6.1 nightly linux pipelines
**even if they opted out of 6.0**.
2025-01-22 08:26:58 +00:00
Cory BenfieldandGeorge Barnett e2bfe0875b Adopt optimized isolated path for SelectableEL (#3075)
Motivation:

Users of SelectableEventLoop deserve to have their code that uses the
isolated event loop view perform at least as well as the code that
doesn't.

Modifications:

- Adopt the extra protocol witnesses.
- Refactor out common code.

Result:

Better performance

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-21 16:36:41 +00:00
Cory Benfield 5771d50865 Enable optimized Isolated view path for AsyncTestingEL (#3074)
Motivation:

NIOAsyncTestingEL is another place where we can reduce the overhead of
the isolated EL views. It's nice for the tests to run faster.

Modifications:

- Implement the new protocol witnesses for AsyncTestingEL
- Refactor common code for scheduleTask out

Result:

AsyncTestingEL is faster.
2025-01-21 16:04:37 +00:00
Cory Benfield 0e9b8378ba Fast-path isolated view for EmbeddedEventLoop (#3073)
Motivation:

This patch takes advantage of the fast-path for isolated views on
EmbeddedEventLoop, reducing overhead when using EmbeddedEL.

Modifications:

- Implement the new witnesses in EmbeddedEL

Result:

EmbeddedEL is faster when using isolated views.
2025-01-20 17:08:14 +00:00
bf41ad1595 Improve HTTPHeaders description performance (#3063)
### Motivation:

As outlined in this
[issue](https://github.com/apple/swift-nio/issues/2930) by @weissi, the
current performance of calling `description` on `HTTPHeaders` is
undermined by the dynamism of Array.

### Modifications:

The proposed solution replaces the implementation of `description` to
iterate over the items and print them out manually. This provides a
faster solution since we bypass the cost of calling into `description`
of an Array.


### Result:

A more performant implementation of `HTTPHeaders` description.

---------

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-01-20 16:39:21 +00:00
Cory Benfield fd6eb16ae5 Ensure we test the isolated fallback methods (#3072)
Motivation

I'm about to change all our main event loops to use our new
customisation points. That's great, but it'll have the effect of
removing all the testing of our default implementations, which is not a
good idea. So let's add some more tests.

Modifications

Define a "fallback" event loop for testing the isolated methods.

Result

Reduced likelihood of regressions in future.
2025-01-20 16:09:52 +00:00
Cory BenfieldandGeorge Barnett 77c1b79c6c Move Isolated EL operations to EL protocol (#3070)
Motivation

Right now the isolated view on the EventLoop has to implement its
interface in terms of UnsafeTransfer, because there are no non-Sendable
operations it can use.

That hurts us because we have to allocate an extra closure for all these
operations, making them slower than they need to be. This is unavoidable
in some contexts, but most EventLoops would be able to offer a fast-path
that avoids this extra allocation.

To achieve that, we need to move this logic into a customisation point
on the EventLoop protocol. Our fallback default implementation can be
the same as we do today.

Modifications

- Add customisation points for EventLoop for each of its operations that
has a protocol witness already.
- Add default implementations of these, using the implementation from
EventLoop.Isolated.

Results

No behavioural changes, but the code has moved.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-20 14:06:21 +00:00
456ca25693 Adds Int(buffer:) initializer to FixedWidthInteger types (#3047)
### Motivation:

Makes it possible to make integers out of ByteBuffers directly with an
initializer. I.e. `UInt32(buffer: ByteBuffer(bytes: [0, 1, 2, 3]))`.
Closes #3012.

### Modifications:

- Adds the `Int(buffer:)` initializer in `ByteBuffer-int.swift`
- Adds tests in `ByteBufferTest.swift`. _Holy hell this file is huge._
- Note that `Int(buffer:)` will crash if the buffer does not have enough
bytes in it to represent the desired integer type.
- It also does _not_ expose endianness and uses `Endianness.host`, to
keep the public API clean and simple. It's a convenience initializer, so
I thought keeping it minimal is a good idea.

### Result:

Nicer direct initializer for integers from ByteBuffers.

---------

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-01-17 17:13:40 +00:00
Cory Benfield 853619335d Improve coverage of isolated views (#3069)
Motivation:

We were only testing the isolated views on SelectableEventLoop. That was
fine when all the implementation was common, but it isn't going to be
anymore, so we should start having tests across all our EL kinds.

Modifications:

Refactor the tests to take their EL as an argument
Add support for ELs that need to be explicitly run 
Add tests for NIOAsyncTestingEL and EmbeddedEL

Result:

Better test coverage.
2025-01-17 14:15:35 +00:00
Cory Benfield 15a38aef06 Add allocation counter tests for isolated EL operations (#3068)
Motivation:

As with the ELF operations before them, the isolated EL operations
currently incur overhead above-and-beyond the overhead of their
non-isolated counterparts. That's not what we want to see. However,
before we "fix" them, we need to add regression testing to confirm our
fix actually worked.

Modifications:

- Add isolated variations of all current EL scheduling tests.
- Where isolated methods didn't have alloc counter tests, add new ones
for the non-isolated versions too.

Result:

More tests.
2025-01-17 10:31:53 +00:00
Natik GadzhiandCory Benfield f5773c171c feat: NIO.TimeAmount(string:) and TimeAmount.description (#3046)
Adds `TimeAmount.init(string:)` and `TimeAmount.description` for parsing
time amounts from strings and pretty printing them.

Closes #2504.

### Motivation:

Had a minute, wanted to work on Swift-NIO a bit more, and saw @weissi
still wanted this.

### Modifications:

It's largely based on the snippet @weissi made in #2504 with a few
changes:
- Added unit tests.
- Added support for more unit aliases for convenience based on
@glbrntt's suggestion.
- Changed `.gitignore` to ignore `.build` everywhere, I've got a few of
them when testing locally.


### Open questions:

- I originally thought perhaps I should add support for multiple number
and unit pairs, i.e. `1h 31m`, but decided against it. Feels like an
edge case. Happy to add this if you think it's needed.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-01-16 16:05:51 +00:00
30e1f2e3f4 feat: Add String(contentsOf: FilePath ...) (#3048)
### Motivation:

Makes it possible to read contents of an NIOFileSystem.FilePath into a
String directly. Closes #3010.

### Modifications:

- Added a new `String+FileSystem.swift` into `NIOFileSystem` target.
- Added basic tests to the existing `ConvenienceTests.swift`.
- Added a test to cover `Array+FileSystem` initializer as well.

### Result:

- String initializer for `FilePath` is now available
- Array initializer for `FilePath` now has a test

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-01-16 12:25:15 +00:00
John Zhou 2620f8e9a0 Fix WebSocketProtocolErrorHandler sending the close frame with appropriate masking key (#3040)
Enhance `WebSocketProtocolErrorHandler` to correctly add masking key for
client/server.

### Motivation:
In `NIOWebSocket`, the automatic error handling provided by
`WebSocketProtocolErrorHandler` offers a convenient way for both clients
and servers to handle protocol-level errors. However, the
`WebSocketFrame` used in `WebSocketProtocolErrorHandler` does not fully
adhere to the RFC 6455 standard. Specifically, as per [RFC 6455 Section
5.1](https://datatracker.ietf.org/doc/html/rfc6455#section-5.1), a
client *must* mask all frames it sends to the server, while a server
*must not* mask any frames it sends to the client. This PR addressed
this discrepancy to ensure compliance with the WebSocket protocol.

### Modifications:
In the `WebSocketProtocolErrorHandler` initializer, the user can specify
whether the handler is used for a WebSocket client or server. Within the
`errorCaught` method, the `WebSocketFrame` will include a maskingKey if
the handler is used by a client, or nil if it is used by a server.

Additionally, the `@unchecked` annotation is removed from
`NIOWebSocketServerUpgrader` since the project is now using swift 5.9
toolchain.

### Result:
The `WebSocketProtocolErrorHandler` is more robust and can correctly
close the connection is error occurs.
2025-01-16 11:08:33 +00:00
Cory Benfield ba72f31e11 Add some trivial Sendable annotations (#3060)
Motivation

We have a few types lying around that can trivially be Sendable, and
that `-require-explicit-sendable` needs to be `Sendable`. Let's add
those annotations.

Modifications

Made a few types Sendable

Result

One step closer to our strict concurrency goal
2.79.0
2025-01-15 09:41:12 +00:00
Cory Benfield 6ac01d1734 Clean up sendability in the bootstraps (#3051)
### Motivation:

The bootstraps are the next most obvious target for cleaning up
Sendability issues. These issues are mostly just missing annotations,
but there are a few places where we had actual latent threading bugs
that were missed. A lot more of the control flow is made more explicit
in this patch, and in general it should get a lot easier to be confident
that the code is correct.

### Modifications:

- Add necessary `@Sendable` annotations
- Clean up some incorrect `self` captures of bootstraps, which are not
`Sendable`, and which could lead to real threading bugs
- Make a few methods `static` to avoid needing to capture `self` at all.
- Make a few threading assumptions clear by using the isolated views or
the sync operations
- Add some missing `Sendable` constraints on interior generic functions.

### Result:

Better safety, better correctness in the bootstraps.
2025-01-14 20:49:33 +00:00
Manolo van Ee ed8e3950a8 Remove unnecessary 'FIXME' comment (#3059)
This was left in when pull request #3044 was merged, but as discussed on
that pull request, this doesn't need to be fixed.
2025-01-14 16:58:52 +00:00
Cory BenfieldandJohannes Weiss 96877aff7f Fix compiling on 6.1 (#3057)
Motivation:

Swift 6.1 nightlies have added many new warnings and errors to NIO. This
patch resolves all of them.

Modifications:

- Clean up missing imports
- Move away from @_implementationOnly where necessary
- Fix a few things where Sendable mismatches were present.

Result:

Clean compile again

---------

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2025-01-14 16:36:17 +00:00
Manolo van EeandCory Benfield 6fb31ea689 NIOAsyncWriter: Fix suspending yield when writer is finished (#3044)
This fixes hitting the following preconditionFailure in NIOAsyncWriter:
"This should have already been handled by `yield()`".

It doesn't expect a yield to be suspended when the state is
`.writerFinished`, but this can definitely happen. This seemed to be the
correct solution to me, but please check it carefully, because I'm
unfamiliar with this code.

I'm not happy about the test for this. It's blocking the `didYield` call
for a while, to make sure the correct state is reached. See also the
'FIXME' line. What would be a better way to do this?

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-01-14 15:28:58 +00:00
hamzahrmalik 9d7cf6825e Clarify docs on EventLoopFuture/assumeIsolatedUnsafeUnchecked (#3058)
- Clarify that it will only crash on release builds
- Fix the claim that the function can be used from async contexts (it is
marked noasync)
2025-01-14 14:13:20 +00:00