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

Convert Lucene volatile long/double values to Atomic counterparts, #1063 #1064

Merged
merged 8 commits into from
Dec 15, 2024

Conversation

paulirwin
Copy link
Contributor

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Convert long/double values that are volatile in Lucene (but can't be in .NET) to AtomicInt64 or (new) AtomicDouble.

Fixes #1063

Description

Since we can't use volatile on 64-bit values in .NET, this doesn't work for long or double. This PR changes volatile long fields to be AtomicInt64 from J2N, as well as introduces a new internal AtomicDouble type in Support for those values, using bit conversion to/from long internally so that we can use Interlocked on it.

@paulirwin paulirwin marked this pull request as ready for review December 12, 2024 19:11
src/Lucene.Net/Support/Threading/AtomicDouble.cs Outdated Show resolved Hide resolved
src/Lucene.Net/Support/Threading/AtomicDouble.cs Outdated Show resolved Hide resolved
src/Lucene.Net/Support/Threading/AtomicDouble.cs Outdated Show resolved Hide resolved
src/Lucene.Net/Support/Threading/AtomicDouble.cs Outdated Show resolved Hide resolved
src/Lucene.Net/Support/Threading/AtomicDouble.cs Outdated Show resolved Hide resolved
src/Lucene.Net/Index/IndexWriter.cs Show resolved Hide resolved
src/Lucene.Net/Index/IndexWriter.cs Show resolved Hide resolved
src/Lucene.Net/Index/IndexWriter.cs Show resolved Hide resolved
src/Lucene.Net/Index/IndexWriter.cs Show resolved Hide resolved
src/Lucene.Net/Index/IndexWriter.cs Show resolved Hide resolved
Copy link
Contributor

@NightOwl888 NightOwl888 left a comment

Choose a reason for hiding this comment

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

I found a couple more minor issues with parameter/variable naming and the fact that TryFormat wasn't overridden and pushed a couple of commits. I have opened NightOwl888/J2N#125 and NightOwl888/J2N#126 to address some of the issues that were discovered here in J2N.

@paulirwin paulirwin merged commit 7cfc4c3 into apache:master Dec 15, 2024
267 checks passed
@paulirwin paulirwin deleted the issue/1063-1 branch December 15, 2024 16:00
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.

Review for volatile 64-bit compatibility
2 participants