-
Notifications
You must be signed in to change notification settings - Fork 327
#1597 - Migrate DocumentManager to use ThreadSafeBox #2396
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
base: main
Are you sure you want to change the base?
#1597 - Migrate DocumentManager to use ThreadSafeBox #2396
Conversation
ahoppen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. That looks easier than I imagined.
Replaces DispatchQueue with ThreadSafeBox, relaxes T: Sendable constraints, and removes @unchecked Sendable from Document.
|
I have pushed the refactored threading model as discussed. The implementation now uses a modernised ThreadSafeBox to manage the document registry. Key Technical Highlights: Verification: Verified the build and successfully ran "swift test". |
|
Hi @ahoppen, I'll ensure that my name and commit identity remain consistent so you can still track my progress from Mark 2 easily. Does this switch work for you? - as my account got approved for education pack of GitHub😊 Thanks! |
ahoppen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Looks good to me 👍🏽
|
@swift-ci Please test |
Absolutely! Contribute with whichever GitHub account you prefer. |
Following the discussion in #1597, this PR migrates the documents dictionary in DocumentManager from a DispatchQueue to a ThreadSafeBox.
This approach was chosen to keep the DocumentManager APIs synchronous while still ensuring thread safety.
Changes:
1-Replaced DispatchQueue with ThreadSafeBox<[DocumentURI: Document]>.
2-Updated all call sites (open, close, edit, etc.) to use .withLock.
3-Marked the Document class as @unchecked Sendable to satisfy ThreadSafeBox requirements.
4-Cleaned up imports (removed Dispatch, added SwiftExtensions).
Note:Verified locally with swift test; all relevant tests passed.