mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
Misc optimization
This commit is contained in:
@@ -30,7 +30,7 @@ using ArchiSteamFarm.Core;
|
||||
namespace ArchiSteamFarm.Helpers;
|
||||
|
||||
internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossProcessSemaphore, IDisposable {
|
||||
private const ushort SpinLockDelay = 1000; // In milliseconds
|
||||
private const byte SpinLockDelay = 200; // In milliseconds
|
||||
|
||||
private readonly string FilePath;
|
||||
private readonly SemaphoreSlim LocalSemaphore = new(1, 1);
|
||||
@@ -125,16 +125,12 @@ internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossP
|
||||
try {
|
||||
stopwatch.Stop();
|
||||
|
||||
if (stopwatch.ElapsedMilliseconds >= int.MaxValue) {
|
||||
if (stopwatch.ElapsedMilliseconds >= millisecondsTimeout) {
|
||||
return false;
|
||||
}
|
||||
|
||||
millisecondsTimeout -= (int) stopwatch.ElapsedMilliseconds;
|
||||
|
||||
if (millisecondsTimeout <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
// ReSharper disable once SuspiciousLockOverSynchronizationPrimitive - this is not a mistake, we need extra synchronization, and we can re-use the semaphore object for that
|
||||
|
||||
Reference in New Issue
Block a user