private void SignalOrReset() { // Should be invoked under lock only if (_connections.Count == 0) { // no connections are available, clear the signal flag _semaphoreSlimSignalable.Reset(); } else { // signal that connections are available _semaphoreSlimSignalable.Signal(); } }
public void Clear() { lock (_poolState) { _poolState.ThrowIfNotInitialized(); if (_poolState.TransitionState(State.Paused)) { _clearingEventHandler?.Invoke(new ConnectionPoolClearingEvent(_serverId, _settings)); _maintenanceHelper.Cancel(); _generation++; _maxConnectionsQueue.Signal(); _maxConnectingQueue.Signal(); _clearedEventHandler?.Invoke(new ConnectionPoolClearedEvent(_serverId, _settings)); } } }
public void Clear(bool closeInUseConnections = false) { lock (_poolState) { _poolState.ThrowIfNotInitialized(); if (_poolState.TransitionState(State.Paused)) { _clearingEventHandler?.Invoke(new ConnectionPoolClearingEvent(_serverId, _settings)); int?maxGenerationToReap = closeInUseConnections ? _generation : null; _generation++; _maintenanceHelper.Stop(maxGenerationToReap); _maxConnectionsQueue.Signal(); _maxConnectingQueue.Signal(); _clearedEventHandler?.Invoke(new ConnectionPoolClearedEvent(_serverId, _settings)); } } }