예제 #1
0
        private void FindHeartbeatCounter(CountersReader counters)
        {
            var heartbeatCounterId = ServiceHeartbeat.FindCounterId(counters, ctx.ServiceId());

            if (CountersReader.NULL_COUNTER_ID == heartbeatCounterId)
            {
                throw new InvalidOperationException("failed to find heartbeat counter");
            }

            heartbeatCounter = new AtomicCounter(counters.ValuesBuffer, heartbeatCounterId);
        }
예제 #2
0
        private AtomicCounter AwaitHeartbeatCounter(CountersReader counters)
        {
            idleStrategy.Reset();
            int counterId = ServiceHeartbeat.FindCounterId(counters, ctx.ServiceId());

            while (CountersReader.NULL_COUNTER_ID == counterId)
            {
                CheckInterruptedStatus();
                idleStrategy.Idle();
                counterId = ServiceHeartbeat.FindCounterId(counters, ctx.ServiceId());
            }

            return(new AtomicCounter(counters.ValuesBuffer, counterId));
        }