[corlib] Fix ConcurrentStack TryPopRange to update count atomically
authorJeremie Laval <jeremie.laval@gmail.com>
Thu, 26 Jul 2012 15:59:24 +0000 (16:59 +0100)
committerJeremie Laval <jeremie.laval@gmail.com>
Thu, 26 Jul 2012 16:01:39 +0000 (17:01 +0100)
mcs/class/corlib/System.Collections.Concurrent/ConcurrentStack.cs

index 05a5ad976163a899fba74011ad5592ee9a6d81b5..931212dc3c019d65c81911ae52d02c25ebcb6163 100644 (file)
@@ -177,7 +177,7 @@ namespace System.Collections.Concurrent
                                temp = temp.Next;
                                pool.Release (ZeroOut (end));
                        }
-                       this.count -= (i - startIndex);
+                       Interlocked.Add (ref this.count, -(i - startIndex));
                        
                        return i - startIndex;
                }