public void HandleFailure(string identifier) { LogonAttempts attempts = _logonDict.GetOrAdd( identifier, key => new LogonAttempts(_maxAttempts)); attempts.PutNext(); }
public LogonAttempts Merge(LogonAttempts replaced) { lock (_locker) lock (replaced._locker) { DateTime[] buffer = _queue.Buffer; DateTime lastTime = buffer[_queue.Head]; var mergedTimes = replaced.GetAccessTimes() .SkipWhile(t => t <= lastTime); foreach (var newTime in mergedTimes) { buffer[_queue.Head] = newTime; _queue.Head = (_queue.Head + 1) % buffer.Length; } Interlocked.Exchange(ref replaced._queue, _queue); } return(this); }