Skip to content

Commit

Permalink
SWEEP: Reviewed all applications of .IncrementAndGet(), .GetAndIncrem…
Browse files Browse the repository at this point in the history
…ent(), .DecrementAndGet(), and .GetAndDecrement() from atomic numeric classes. Closes #917.
  • Loading branch information
NightOwl888 committed Mar 10, 2024
1 parent a47a11a commit cd79a44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/Lucene.Net.Replicator/LocalReplicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;

Expand Down Expand Up @@ -189,7 +190,7 @@ public virtual SessionToken CheckForUpdate(string currentVersion)
// currentVersion is either null or older than latest published revision
currentRevision.IncRef();

string sessionID = sessionToken.IncrementAndGet().ToString();
string sessionID = sessionToken.IncrementAndGet().ToString(CultureInfo.InvariantCulture);
SessionToken token = new SessionToken(sessionID, currentRevision.Revision);
sessions[sessionID] = new ReplicationSession(token, currentRevision);
return token;
Expand Down Expand Up @@ -329,4 +330,4 @@ public virtual void Release(string sessionId)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public override long GetCost()
// Holds all indexes created, keyed by the ID assigned in fieldsConsumer
private readonly IDictionary<int, RAMPostings> state = new Dictionary<int, RAMPostings>();

private readonly AtomicInt64 nextID = new AtomicInt64();
private readonly AtomicInt32 nextID = new AtomicInt32();

private readonly string RAM_ONLY_NAME = "RAMOnly";
private const int VERSION_START = 0;
Expand All @@ -582,7 +582,7 @@ public override long GetCost()

public override FieldsConsumer FieldsConsumer(SegmentWriteState writeState)
{
int id = (int)nextID.GetAndIncrement();
int id = nextID.GetAndIncrement();

// TODO -- ok to do this up front instead of
// on close....? should be ok?
Expand Down Expand Up @@ -659,4 +659,4 @@ public override FieldsProducer FieldsProducer(SegmentReadState readState)
}
}
}
}
}

0 comments on commit cd79a44

Please sign in to comment.