Conversation
Member
|
Thanks for the PR! Stately isn't under active development, so it may take some time to get it reviewed |
There was a problem hiding this comment.
🟡 Changes recommended
The native constructor visibility change breaks existing callers and needs compatibility handling or explicit documentation.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds cleaner-backed native lock ownership to Synchronizable, with a GC regression test.
Changes:
- Adds cleaner-based native lock cleanup.
- Verifies cleanup occurs exactly once.
- Changes the native constructor visibility.
Review note: The constructor visibility change is API-breaking for native callers and should preserve the public overload or be explicitly documented.
File summaries
| File | Description |
|---|---|
stately-concurrency/src/nativeTest/kotlin/co/touchlab/stately/concurrency/SynchronizableTest.kt |
Tests native lock cleanup after garbage collection. |
stately-concurrency/src/nativeMain/kotlin/co/touchlab/stately/concurrency/Functions.kt |
Adds cleaner-backed native synchronization resources. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| import kotlin.native.ref.createCleaner | ||
|
|
||
| fun <R> runSynchronized(block: () -> R): R = _lock.withLock(block) | ||
| actual open class Synchronizable internal constructor(private val resource: SynchronizationResource) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Owns the native
Lockin a cleaner-backed resource soSynchronizablecloses it when it becomes unreachable. Adds a native GC regression test that verifies cleanup happens exactly once.Tests: native and JVM suites, ktlint, and API validation.
Closes #117.