Skip to content

Commit b60b864

Browse files
committed
Misc
1 parent 4c64141 commit b60b864

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

ArchiSteamFarm/ConcurrentHashSet.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,20 @@ internal sealed class ConcurrentHashSet<T> : ICollection<T>, IDisposable {
3434
private readonly ReaderWriterLockSlim Lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
3535

3636
public bool IsReadOnly => false;
37-
3837
public IEnumerator<T> GetEnumerator() => new ConcurrentEnumerator<T>(HashSet, Lock);
3938

39+
public int Count {
40+
get {
41+
Lock.EnterReadLock();
42+
43+
try {
44+
return HashSet.Count;
45+
} finally {
46+
Lock.ExitReadLock();
47+
}
48+
}
49+
}
50+
4051
[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global")]
4152
public bool Add(T item) {
4253
Lock.EnterWriteLock();
@@ -89,18 +100,6 @@ public bool Remove(T item) {
89100
}
90101
}
91102

92-
public int Count {
93-
get {
94-
Lock.EnterReadLock();
95-
96-
try {
97-
return HashSet.Count;
98-
} finally {
99-
Lock.ExitReadLock();
100-
}
101-
}
102-
}
103-
104103
public void Dispose() {
105104
if (Lock != null) {
106105
Lock.Dispose();
@@ -121,4 +120,4 @@ public void CopyTo(T[] array, int arrayIndex) {
121120

122121
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
123122
}
124-
}
123+
}

0 commit comments

Comments
 (0)