Exemplo n.º 1
0
        private void AwaitResponse(long correlationId, string expectedChannel)
        {
            _driverException = null;
            var deadlineNs = _nanoClock.NanoTime() + _driverTimeoutNs;

            do
            {
                if (null == _driverAgentInvoker)
                {
                    Aeron.Sleep(1);
                }
                else
                {
                    _driverAgentInvoker.Invoke();
                }

                DoWork(correlationId, expectedChannel);

                if (_driverListener.LastReceivedCorrelationId() == correlationId)
                {
                    if (null != _driverException)
                    {
                        throw _driverException;
                    }

                    return;
                }
            } while (_nanoClock.NanoTime() < deadlineNs);

            throw new DriverTimeoutException("No response from driver wihtout timeout");
        }
Exemplo n.º 2
0
        private void AwaitResponse(long correlationId, string expectedChannel, bool isSlowOperation)
        {
            _driverException = null;
            var timeout = _nanoClock.NanoTime() + _driverTimeoutNs;

            do
            {
                if (isSlowOperation)
                {
                    Thread.Sleep(1);
                }
                else
                {
                    Thread.Yield();
                }

                DoWork(correlationId, expectedChannel);

                if (_driverListener.LastReceivedCorrelationId() == correlationId)
                {
                    if (null != _driverException)
                    {
                        throw _driverException;
                    }

                    return;
                }
            } while (_nanoClock.NanoTime() < timeout);

            throw new DriverTimeoutException("No response from driver within timeout");
        }
Exemplo n.º 3
0
        private void DoWorkUntil(long correlationId, long timeout, string expectedChannel)
        {
            _driverException = null;

            do
            {
                DoWork(correlationId, expectedChannel);

                if (_driverListener.LastReceivedCorrelationId() == correlationId)
                {
                    if (null != _driverException)
                    {
                        throw _driverException;
                    }

                    return;
                }
            } while (_nanoClock.NanoTime() < timeout);

            throw new DriverTimeoutException("No response from driver within timeout");
        }