public void OnClose() { bool isInterrupted = false; _clientLock.Lock(); try { if (!_isClosed) { if (!_aeron.IsClosed) { _aeron.InternalClose(); } ForceCloseResources(); NotifyCloseHandlers(); try { if (_isTerminating) { Thread.Sleep(Aeron.Configuration.IdleSleepMs); } Thread.Sleep((int)TimeUnit.NANOSECONDS.toMillis(_ctx.CloseLingerDurationNs())); } catch (ThreadInterruptedException) { isInterrupted = true; } for (int i = 0, size = _lingeringLogBuffers.Count; i < size; i++) { CloseHelper.Dispose(_ctx.ErrorHandler(), _lingeringLogBuffers[i]); } _driverProxy.ClientClose(); _ctx.Dispose(); } } finally { _isClosed = true; if (isInterrupted) { Thread.CurrentThread.Interrupt(); } _clientLock.Unlock(); } }
private int CheckLingeringResources(long nowNs) { int workCount = 0; for (int lastIndex = _lingeringLogBuffers.Count - 1, i = lastIndex; i >= 0; i--) { LogBuffers logBuffers = _lingeringLogBuffers[i]; if (logBuffers.LingerDeadlineNs() - nowNs < 0) { ListUtil.FastUnorderedRemove(_lingeringLogBuffers, i, lastIndex--); CloseHelper.Dispose(_ctx.ErrorHandler(), logBuffers); workCount += 1; } } return(workCount); }
public void OnClose() { aeron.RemoveCloseHandler(abortHandler); if (isAbort) { ctx.AbortLatch().Signal(); } else { ErrorHandler errorHandler = ctx.CountedErrorHandler().OnError; if (isServiceActive) { isServiceActive = false; try { service.OnTerminate(this); } catch (Exception ex) { errorHandler(ex); } } if (!ctx.OwnsAeronClient() && !aeron.IsClosed) { foreach (var session in sessionByIdMap.Values) { session.Disconnect(errorHandler); } CloseHelper.Dispose(errorHandler, logAdapter); CloseHelper.Dispose(errorHandler, _serviceAdapter); CloseHelper.Dispose(errorHandler, _consensusModuleProxy); } } ctx.Dispose(); }
internal void Disconnect(ErrorHandler errorHandler) { CloseHelper.Dispose(errorHandler, _responsePublication); _responsePublication = null; }