mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Remove denepdency on Nito.AsyncEx.Coordination
We don't really need async operations here, ReaderWriterLockSlim is enough
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace ArchiSteamFarm.Collections {
|
||||
@@ -29,22 +30,24 @@ namespace ArchiSteamFarm.Collections {
|
||||
public T Current => Enumerator.Current;
|
||||
|
||||
private readonly IEnumerator<T> Enumerator;
|
||||
private readonly IDisposable Lock;
|
||||
private readonly ReaderWriterLockSlim Lock;
|
||||
|
||||
object IEnumerator.Current => Current;
|
||||
|
||||
internal ConcurrentEnumerator([NotNull] IReadOnlyCollection<T> collection, [NotNull] IDisposable @lock) {
|
||||
internal ConcurrentEnumerator([NotNull] IReadOnlyCollection<T> collection, [NotNull] ReaderWriterLockSlim @lock) {
|
||||
if ((collection == null) || (@lock == null)) {
|
||||
throw new ArgumentNullException(nameof(collection) + " || " + nameof(@lock));
|
||||
}
|
||||
|
||||
@lock.EnterReadLock();
|
||||
|
||||
Lock = @lock;
|
||||
Enumerator = collection.GetEnumerator();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Enumerator.Dispose();
|
||||
Lock.Dispose();
|
||||
Lock.ExitReadLock();
|
||||
}
|
||||
|
||||
public bool MoveNext() => Enumerator.MoveNext();
|
||||
|
||||
Reference in New Issue
Block a user