Пример #1
0
        private int OnCheckTimeouts()
        {
            int  workCount = 0;
            long nowNs     = _nanoClock.NanoTime();

            if (nowNs < (_timeOfLastWorkNs + Aeron.IdleSleepNs))
            {
                return(workCount);
            }

            if (nowNs > (_timeOfLastWorkNs + _interServiceTimeoutNs))
            {
                OnClose();

                throw new ConductorServiceTimeoutException("Timeout between service calls over " + _interServiceTimeoutNs + "ns");
            }

            _timeOfLastWorkNs = nowNs;

            if (nowNs > (_timeOfLastKeepaliveNs + _keepAliveIntervalNs))
            {
                _driverProxy.SendClientKeepalive();
                CheckDriverHeartbeat();

                _timeOfLastKeepaliveNs = nowNs;
                workCount++;
            }

            if (nowNs > (_timeOfLastCheckResourcesNs + RESOURCE_TIMEOUT_NS))
            {
                List <IManagedResource> lingeringResources = _lingeringResources;
                for (int lastIndex = lingeringResources.Count - 1, i = lastIndex; i >= 0; i--)
                {
                    IManagedResource resource = lingeringResources[i];
                    if (nowNs > (resource.TimeOfLastStateChange() + RESOURCE_LINGER_NS))
                    {
                        ListUtil.FastUnorderedRemove(lingeringResources, i, lastIndex);
                        lastIndex--;
                        resource.Delete();
                    }
                }

                _timeOfLastCheckResourcesNs = nowNs;
                workCount++;
            }

            return(workCount);
        }
        private int CheckLingeringResources(long nowNs)
        {
            int workCount = 0;

            var lingeringResources = _lingeringResources;

            for (int lastIndex = lingeringResources.Count - 1, i = lastIndex; i >= 0; i--)
            {
                IManagedResource resource = lingeringResources[i];

                if ((resource.TimeOfLastStateChange() + _ctx.ResourceLingerDurationNs()) - nowNs < 0)
                {
                    ListUtil.FastUnorderedRemove(lingeringResources, i, lastIndex--);
                    resource.Delete();
                    workCount++;
                }
            }

            return(workCount);
        }
Пример #3
0
        private int checkLingeringResources(long nowNs)
        {
            if (nowNs > (_timeOfLastResourcesCheckNs + RESOURCE_CHECK_INTERVAL_NS))
            {
                List <IManagedResource> lingeringResources = _lingeringResources;
                for (int lastIndex = lingeringResources.Count - 1, i = lastIndex; i >= 0; i--)
                {
                    IManagedResource resource = lingeringResources[i];

                    if (nowNs > (resource.TimeOfLastStateChange() + RESOURCE_LINGER_NS))
                    {
                        ListUtil.FastUnorderedRemove(lingeringResources, i, lastIndex--);
                        resource.Delete();
                    }
                }

                _timeOfLastResourcesCheckNs = nowNs;

                return(1);
            }

            return(0);
        }