Skip to content

Commit

Permalink
improve sync with Temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Jul 15, 2024
1 parent d175ffb commit 6bc0faa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Project-Aurora/Project-Aurora/Utils/Temporary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public T Value
return _value;
}

//TODO add an infinite loop check
var value = produce.Invoke();
_value = value;
ValueCreated?.Invoke(this, EventArgs.Empty);
Expand Down Expand Up @@ -110,19 +111,19 @@ private static Timer StartAliveTimer()

private static void AliveTimerCallback(object? state)
{
TimerLock.EnterReadLock();
TimerLock.EnterWriteLock();

Instances.RemoveAll(ExpiredInstance);
if (Instances.Count != 0)
{
TimerLock.ExitReadLock();
TimerLock.ExitWriteLock();
return;
}

_aliveTimer?.Dispose();
_aliveTimer = null;

TimerLock.ExitReadLock();
TimerLock.ExitWriteLock();
}

private static bool ExpiredInstance(Temporary<T> temporary)
Expand Down

0 comments on commit 6bc0faa

Please sign in to comment.