Skip to content

Fix FileHandle thread safety on native platforms#1780

Open
MohammadKHC wants to merge 5 commits intosquare:masterfrom
MohammadKHC:fix-filehandle
Open

Fix FileHandle thread safety on native platforms#1780
MohammadKHC wants to merge 5 commits intosquare:masterfrom
MohammadKHC:fix-filehandle

Conversation

@MohammadKHC
Copy link
Contributor

@MohammadKHC MohammadKHC commented Feb 12, 2026

Replace no-op Lock with AtomicBoolean/AtomicInt for proper synchronization.

Is it fine to delete newLock() completely? Lock is public but newLock() is internal, and FileHandle was the only place using it.

Closes #1778

@MohammadKHC
Copy link
Contributor Author

Or should we just implement the Lock for native?

I think that Atomics should be more efficient for this use case.

@MohammadKHC
Copy link
Contributor Author

@JakeWharton Okay! instead of using atomics,
I implemented Lock for Unix and Windows.

Can you review it again?

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.

FileHandle is not thread-safe on native due to no-op Lock implementation.

2 participants