lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [09/12] lucenenet git commit: GetAndIncrement should return one less the final value of the synchronized variable, after incrementing it. It was generating a race condition because a few threads could read the same value.
Date Tue, 17 Feb 2015 17:29:51 GMT
GetAndIncrement should return one less the final value of the synchronized variable, after
incrementing it. It was generating a race condition because a few threads could read the same
value.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/0548f769
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/0548f769
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/0548f769

Branch: refs/heads/master
Commit: 0548f7694caa12ef2f47ea9bed2bf5c2cb9275d7
Parents: 460692d
Author: Guido Tagliavini Ponce <t-gupon@microsoft.com>
Authored: Mon Feb 16 19:18:33 2015 -0800
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Tue Feb 17 19:22:00 2015 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Core/Support/AtomicInteger.cs | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/0548f769/src/Lucene.Net.Core/Support/AtomicInteger.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/AtomicInteger.cs b/src/Lucene.Net.Core/Support/AtomicInteger.cs
index 017926a..5f2e9dd 100644
--- a/src/Lucene.Net.Core/Support/AtomicInteger.cs
+++ b/src/Lucene.Net.Core/Support/AtomicInteger.cs
@@ -23,9 +23,7 @@ namespace Lucene.Net.Support
 
         public int GetAndIncrement()
         {
-            int ret = value;
-            Interlocked.Increment(ref value);
-            return ret;
+            return Interlocked.Increment(ref value) - 1;
         }
 
         public int DecrementAndGet()


Mime
View raw message