/// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="statementResultService">handles result delivery</param>
 /// <param name="dispatchService">for performing the dispatch</param>
 /// <param name="msecTimeout">timeout for preserving dispatch order through blocking</param>
 /// <param name="timeSourceService">time source provider</param>
 /// <param name="threadLocalManager">The thread local manager.</param>
 public UpdateDispatchViewBlockingSpin(StatementResultService statementResultService, DispatchService dispatchService, long msecTimeout, TimeSourceService timeSourceService, IThreadLocalManager threadLocalManager)
     : base(statementResultService, dispatchService, threadLocalManager)
 {
     _currentFutureSpin = new UpdateDispatchFutureSpin(timeSourceService); // use a completed future as a start
     _msecTimeout       = msecTimeout;
     _timeSourceService = timeSourceService;
 }
Exemplo n.º 2
0
 /// <summary>Ctor. </summary>
 /// <param name="view">is the blocking dispatch view through which to execute a dispatch</param>
 /// <param name="earlier">is the older future</param>
 /// <param name="msecTimeout">is the timeout period to wait for listeners to complete a prior dispatch</param>
 /// <param name="timeSourceService">time source provider</param>
 public UpdateDispatchFutureSpin(UpdateDispatchViewBlockingSpin view,
                                 UpdateDispatchFutureSpin earlier,
                                 long msecTimeout,
                                 TimeSourceService timeSourceService)
 {
     _view              = view;
     _earlier           = earlier;
     _msecTimeout       = msecTimeout;
     _timeSourceService = timeSourceService;
 }
        public override void NewResult(UniformPair <EventBean[]> result)
        {
            StatementResultService.Indicate(result);

            var isDispatchWaiting = IsDispatchWaiting;

            if (!isDispatchWaiting.Value)
            {
                UpdateDispatchFutureSpin nextFutureSpin;
                lock (this)
                {
                    nextFutureSpin     = new UpdateDispatchFutureSpin(this, _currentFutureSpin, _msecTimeout, _timeSourceService);
                    _currentFutureSpin = nextFutureSpin;
                }
                DispatchService.AddExternal(nextFutureSpin);
                isDispatchWaiting.Value = true;
            }
        }
Exemplo n.º 4
0
        public void Execute()
        {
            if (!_earlier._isCompleted)
            {
                long spinStartTime = _timeSourceService.GetTimeMillis();

                while (!_earlier._isCompleted)
                {
                    Thread.Yield();

                    long spinDelta = _timeSourceService.GetTimeMillis() - spinStartTime;
                    if (spinDelta > _msecTimeout)
                    {
                        Log.Info("Spin wait timeout exceeded in listener dispatch for statement '" + _view.StatementResultService.StatementName + "'");
                        break;
                    }
                }
            }

            _view.Execute();
            _isCompleted = true;

            _earlier = null;
        }