Skip to content

Comments

Make follow-up changes to Locked#131

Merged
mattt merged 9 commits intomainfrom
mattt/locked-follow-up
Feb 17, 2026
Merged

Make follow-up changes to Locked#131
mattt merged 9 commits intomainfrom
mattt/locked-follow-up

Conversation

@mattt
Copy link
Owner

@mattt mattt commented Feb 17, 2026

Follow-up to #126

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Follow-up to #126 that standardizes the Locked synchronization helper and updates call sites to use it consistently when guarding shared mutable state.

Changes:

  • Rename Locked.accessLocked.withLock and move Locked into Sources/AnyLanguageModel/Shared/.
  • Replace ad-hoc NSLock + dictionaries in caches with Locked<...> wrappers.
  • Update LanguageModelSession and tests to use withLock throughout.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Tests/AnyLanguageModelTests/ObservationTests.swift Updates observation tests to use withLock when mutating/reading tracked flags.
Tests/AnyLanguageModelTests/LockedTests.swift Updates Locked unit tests for the renamed API and suite name.
Sources/AnyLanguageModel/Shared/StructuredGeneration.swift Replaces manual NSLock protection of token cache with Locked.
Sources/AnyLanguageModel/Shared/Locked.swift Adds Locked implementation with withLock API and documentation.
Sources/AnyLanguageModel/Models/MLXLanguageModel.swift Replaces manual locking of inFlight task dictionary with Locked.
Sources/AnyLanguageModel/Locked.swift Removes the old Locked implementation from the root source folder.
Sources/AnyLanguageModel/LanguageModelSession.swift Updates session state access/mutations to use withLock consistently.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@atdrendel atdrendel left a comment

Choose a reason for hiding this comment

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

Good stuff. I'm happy to see Locked being used elsewhere in the app. Sadly, it seems like every open source project needs its own implementation, at least until we call all rely on Mutex when requiring iOS 18.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice to see the Locked be used elsewhere in the app.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah, same!

@mattt mattt merged commit d589b79 into main Feb 17, 2026
3 checks passed
@mattt mattt deleted the mattt/locked-follow-up branch February 17, 2026 13:31
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