Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make _NIOFileSystem strict concurrency compatible #3098

Merged
merged 2 commits into from
Feb 3, 2025

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Feb 3, 2025

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

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
@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Feb 3, 2025
@Lukasa
Copy link
Contributor Author

Lukasa commented Feb 3, 2025

Merging over the API breakage.

@Lukasa Lukasa merged commit 08b3b4f into apple:main Feb 3, 2025
31 of 35 checks passed
@Lukasa Lukasa deleted the cb-strict-concurrency-nio-filesystem branch February 3, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants