Further optimize InMemoryServerListProvider and make it thread-safe

This commit is contained in:
JustArchi
2016-08-19 04:57:21 +02:00
parent 214746bca2
commit 2816ecaa90
2 changed files with 19 additions and 8 deletions

View File

@@ -102,6 +102,21 @@ namespace ArchiSteamFarm {
}
}
internal bool ReplaceIfNeededWith(HashSet<T> items) {
Lock.EnterUpgradeableReadLock();
try {
if (HashSet.SetEquals(items)) {
return false;
}
ReplaceWith(items);
return true;
} finally {
Lock.ExitUpgradeableReadLock();
}
}
internal void ReplaceWith(IEnumerable<T> items) {
Lock.EnterWriteLock();