Skip to content

chore: update Lock implementation with latest changes from swift-nio#408

Merged
kukushechkin merged 2 commits intoapple:mainfrom
PassiveLogic:chore/updateLockWithLatestFromNIO
Feb 12, 2026
Merged

chore: update Lock implementation with latest changes from swift-nio#408
kukushechkin merged 2 commits intoapple:mainfrom
PassiveLogic:chore/updateLockWithLatestFromNIO

Conversation

@scottmarchant
Copy link
Copy Markdown
Contributor

Ports changes to Lock from swift-nio to swift-log.

Motivation:

The copy-paste of Lock in swift-log should be updated with changes from swift-nio.

Modifications:

Result:

Lock implementation will have the same implementation as swift-nio (assuming apple/swift-nio#3494 merges).

@scottmarchant scottmarchant marked this pull request as ready for review February 4, 2026 22:20
InitializeSRWLock(self.mutex)
#elseif (compiler(<6.1) && !os(WASI)) || (compiler(>=6.1) && _runtime(_multithreaded))
#if os(FreeBSD) || os(OpenBSD)
#elseif os(FreeBSD) || os(OpenBSD)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're still missing a call to pthread_mutexattr_destroy in the FreeBSD/OpenBSD branch.

Copy link
Copy Markdown
Contributor

@kkebo kkebo Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question. Why is swift-log using swift-nio's deprecated Lock, not the current NIOLock? NIOLock doesn't have such an issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, I've added the fix for it to apple/swift-nio#3494. Thank you.

apple/swift-nio@bcc8d05

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kkebo Thanks, I updated this PR to match the lock implementation in your PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is swift-log using swift-nio's deprecated Lock, not the current NIOLock? NIOLock doesn't have such an issue.

@kkebo I've wondered the same thing. The obvious possible reason I've thought of is that the new lock is named NIOLock, and the repos where Lock is copied don't have anything to do with NIO, so it would be weird for them to have a thing called NIOLock in them.

Honestly, I've wondered why we don't have set up an official Lock and RecursiveLock in Synchronization. This business of copy-pasting a Lock implementation between several repos to avoid inter-dependency isn't the best solution compared to mainstreaming the implementation either in Synchronization or a standalone package.

Anyways, for now, we at least need to keep the implementations in sync. Once this PR merges, I'm planning to synchronize the changes to swift-metrics and swift-distributed-tracing as well (both have copy-pastes of this as well.

@kkebo
Copy link
Copy Markdown
Contributor

kkebo commented Feb 5, 2026

@kkebo Please confirm this works.

I ran swift test on this branch on FreeBSD, and I've confirmed that all tests passed.

@scottmarchant scottmarchant force-pushed the chore/updateLockWithLatestFromNIO branch from 4751f62 to 4982bc6 Compare February 5, 2026 17:38
scottmarchant added a commit to PassiveLogic/swift-metrics that referenced this pull request Feb 5, 2026
… lock implementation to match the latest implementation in swift-log provided by apple/swift-log#408.
@scottmarchant scottmarchant force-pushed the chore/updateLockWithLatestFromNIO branch from 4982bc6 to a0ceb67 Compare February 5, 2026 18:23
scottmarchant added a commit to PassiveLogic/swift-metrics that referenced this pull request Feb 5, 2026
… lock implementation to match the latest implementation in swift-log provided by apple/swift-log#408.
scottmarchant added a commit to PassiveLogic/swift-metrics that referenced this pull request Feb 5, 2026
… lock implementation to match the latest implementation in swift-log provided by apple/swift-log#408.
kukushechkin pushed a commit to apple/swift-distributed-tracing that referenced this pull request Feb 11, 2026
#210)

Ports changes to `Lock` from `swift-nio` and `swift-log` to
`swift-distributed-tracing`.

### Motivation:

The copy-paste of `Lock` in `swift-distributed-tracing` should be
updated with changes from swift-nio.

### Modifications:

- This is a near straight copy of the changes brought from swift-nio to
swift-log in apple/swift-log#408.

### Result:

`Lock` implementation will have the same or nearly the same
implementation as swift-nio (assuming
apple/swift-nio#3494 merges). `Lock` will also
have the same implementation as swift-log, once
apple/swift-log#408 merges.
@kukushechkin kukushechkin added the 🔨 semver/patch No public API change. label Feb 11, 2026
@kukushechkin kukushechkin merged commit 8fb4e71 into apple:main Feb 12, 2026
203 of 206 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants