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

Require ThreadSafeBox.T to be Sendable #1394

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 1, 2024

Otherwise, I think ThreadSafeBox might still have data races. This also requires us to make TestSourceKitLSPClient.RequestHandler sendable.

rdar://128572489

@ahoppen ahoppen requested review from bnbarham and hamishknight June 1, 2024 18:16
@ahoppen ahoppen requested a review from benlangmuir as a code owner June 1, 2024 18:16
@ahoppen
Copy link
Member Author

ahoppen commented Jun 1, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jun 1, 2024

@swift-ci Please test Linux

@@ -24,7 +24,7 @@ extension NSLock {
/// A thread safe container that contains a value of type `T`.
///
/// - Note: Unchecked sendable conformance because value is guarded by a lock.
public class ThreadSafeBox<T>: @unchecked Sendable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, what issues are being caused by it not being Sendable?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the main issue that I noticed was that some of the request handles in TestSourceKitLSPClient weren’t sendable. I didn’t technically hit any bug from it but I was wondering why I could modify local variables from the surrounding context from within the request handler, which generally isn’t safe.

@ahoppen ahoppen force-pushed the thread-safe-box-sendable branch from ccb571f to 2446ab4 Compare June 3, 2024 15:38
@ahoppen
Copy link
Member Author

ahoppen commented Jun 3, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jun 3, 2024

@swift-ci Please test Windows

@ahoppen ahoppen force-pushed the thread-safe-box-sendable branch from 2446ab4 to 5b7d725 Compare June 3, 2024 17:11
@ahoppen
Copy link
Member Author

ahoppen commented Jun 3, 2024

@swift-ci Please test

Otherwise, I think `ThreadSafeBox` might still have data races. This also requires us to make `TestSourceKitLSPClient.RequestHandler` sendable.

rdar://128572489
@ahoppen ahoppen force-pushed the thread-safe-box-sendable branch from 5b7d725 to c7bf59e Compare June 3, 2024 17:23
@ahoppen
Copy link
Member Author

ahoppen commented Jun 3, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jun 3, 2024

@swift-ci Please test Windows

@ahoppen ahoppen enabled auto-merge June 3, 2024 17:34
@ahoppen ahoppen merged commit 3b68f15 into swiftlang:main Jun 3, 2024
3 checks passed
@ahoppen ahoppen deleted the thread-safe-box-sendable branch June 4, 2024 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants