Browse Source

4.x: Fix PriorityQueue to not share a item ordering helper index (#507)

David Karnok 7 years ago
parent
commit
206f770d50
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Rx.NET/Source/src/System.Reactive/Internal/PriorityQueue.cs

+ 2 - 2
Rx.NET/Source/src/System.Reactive/Internal/PriorityQueue.cs

@@ -9,7 +9,7 @@ namespace System.Reactive
 {
     internal sealed class PriorityQueue<T> where T : IComparable<T>
     {
-        private static long _count = long.MinValue;
+        private long _count = long.MinValue;
         private IndexedItem[] _items;
         private int _size;
 
@@ -125,7 +125,7 @@ namespace System.Reactive
             }
 
             var index = _size++;
-            _items[index] = new IndexedItem { Value = item, Id = Interlocked.Increment(ref _count) };
+            _items[index] = new IndexedItem { Value = item, Id = ++_count };
             Percolate(index);
         }