src/AspNetCoreRateLimit/AsyncKeyLock/AsyncKeyLock.cs
/// <summary>
/// Releases a reference to a doorman. If the ref-count hits zero, then the doorman is
/// returned to the pool (or is simply left for the garbage collector to cleanup if the
/// pool is already full).
/// </summary>
/// <param name="doorman">The <see cref="Doorman"/>.</param>
Releases a reference to a doorman. If the ref-count hits zero, then the doorman is
returned to the pool (or is simply left for the garbage collector to cleanup if the
pool is already full).
Releases a reference to a doorman . If the ref - count hits zero then the doorman is returned to the pool ( or is simply left for the garbage collector to cleanup if the pool is already full ) .
private static void ReleaseDoorman(AsyncKeyLockDoorman doorman)
        {
            bool lockTaken = false;
            try
            {
                _spinLock.Enter(ref lockTaken);
                if (--doorman.RefCount == 0)
                {
                    Keys.Remove(doorman.Key);
                    if (Pool.Count < MaxPoolSize)
                    {
                        doorman.Key = null;
                        Pool.Push(doorman);
                    }
                }
            }
            finally
            {
                if (lockTaken)
                {
                    _spinLock.Exit();
                }
            }
        }
private static void ReleaseDoorman ( AsyncKeyLockDoorman doorman ) { bool lockTaken = false ; try { _spinLock . Enter ( ref lockTaken ) ; if ( -- doorman . RefCount == 0 ) { Keys . Remove ( doorman . Key ) ; if ( Pool . Count < MaxPoolSize ) { doorman . Key = null ; Pool . Push ( doorman ) ; } } } finally { if ( lockTaken ) { _spinLock . Exit ( ) ; } } }
Releases a reference to a doorman.
Releases a reference to a doorman .
doorman
AsyncKeyLockDoorman
None