예제 #1
0
 protected void OnReceiveFirstTransfer(Transfer transfer)
 {
     Fx.Assert(transfer.DeliveryId.HasValue, "The first transfer must have a delivery id.");
     this.nextDeliveryId = transfer.DeliveryId.Value;
 }
예제 #2
0
 public DefaultActionItem(WaitCallback callback, object state)
 {
     Fx.Assert(callback != null, "Shouldn't instantiate an object to wrap a null callback");
     this.callback = callback;
     this.state    = state;
 }
예제 #3
0
            public void DisposeDelivery(Delivery delivery, bool settled, DeliveryState state, bool noFlush)
            {
                if (delivery.Settled)
                {
                    this.OnWindowMoved(1);
                    return;
                }

                bool     scheduleTimer = false;
                Delivery toDispose     = null;

                lock (this.syncRoot)
                {
                    delivery.StateChanged = true;
                    delivery.Settled      = settled;
                    delivery.State        = state;

                    if (!delivery.Batchable)
                    {
                        delivery.StateChanged = false;
                        toDispose             = delivery;
                        if (delivery.Settled)
                        {
                            Delivery.Remove(ref this.firstUnsettled, ref this.lastUnsettled, delivery);
                        }
                    }
                    else if (this.sendingDisposition || noFlush)
                    {
                        return;
                    }
                    else if (this.session.settings.DispositionInterval == TimeSpan.Zero ||
                             ++this.needDispositionCount >= this.session.settings.DispositionThreshold)
                    {
                        this.sendingDisposition   = true;
                        this.needDispositionCount = 0;
                    }
                    else if (!this.timerScheduled)
                    {
                        this.timerScheduled = true;
                        scheduleTimer       = true;
                    }
                }

                if (toDispose != null)
                {
                    this.SendDisposition(new DispositionInfo()
                    {
                        First = toDispose
                    });
                    if (delivery.Settled)
                    {
                        this.OnWindowMoved(1);
                    }
                }
                else if (scheduleTimer)
                {
                    Fx.Assert(this.dispositionTimer != null, "Disposition timer cannot be null");
                    this.dispositionTimer.Change(this.session.settings.DispositionInterval, Timeout.InfiniteTimeSpan);
                }
                else
                {
                    this.SendDisposition();
                }
            }
예제 #4
0
 public void Seek(int seekPosition)
 {
     Fx.Assert(seekPosition >= 0, "seekPosition must not be negative.");
     Fx.Assert((this.start + seekPosition) <= this.write, "seekPosition too large.");
     this.read = this.start + seekPosition;
 }
예제 #5
0
 public void Complete(int size)
 {
     Fx.Assert(size >= 0, "size must be positive.");
     Fx.Assert((this.read + size) <= this.write, "Complete size too large.");
     this.read += size;
 }
예제 #6
0
 public void Append(int size)
 {
     Fx.Assert(size >= 0, "size must be positive.");
     Fx.Assert((this.write + size) <= this.end, "Append size too large.");
     this.write += size;
 }
예제 #7
0
 bool CompleteInternal(bool syncComplete, Exception exception)
 {
     Fx.Assert(exception != null || this.setTimerCalled, "Must call SetTimer.");
     return(this.TryComplete(syncComplete, exception));
 }