in src/AmqpSession.cs [1012:1092]
void SendDisposition()
{
List<DispositionInfo> disposedDeliveries = new List<DispositionInfo>();
int settledCount = 0;
lock (this.syncRoot)
{
Delivery current = this.firstUnsettled;
Delivery firstChanged = null;
uint? lastId = null;
while (current != null)
{
if (current.StateChanged)
{
if (firstChanged == null)
{
firstChanged = current;
}
else
{
if (current.Settled == firstChanged.Settled &&
CanBatch(current.State as Outcome, firstChanged.State as Outcome))
{
lastId = current.DeliveryId.Value;
}
else
{
disposedDeliveries.Add(new DispositionInfo(firstChanged, lastId));
firstChanged = current;
lastId = null;
}
}
// Move next and remove if settled
if (current.Settled)
{
Delivery temp = current;
current = current.Next;
++settledCount;
Delivery.Remove(ref this.firstUnsettled, ref this.lastUnsettled, temp);
}
else
{
current.StateChanged = false;
current = current.Next;
}
}
else
{
if (firstChanged != null)
{
disposedDeliveries.Add(new DispositionInfo(firstChanged, lastId));
firstChanged = null;
lastId = null;
}
current = current.Next;
}
}
if (firstChanged != null)
{
disposedDeliveries.Add(new DispositionInfo(firstChanged, lastId));
}
this.sendingDisposition = false;
}
if (disposedDeliveries.Count > 0)
{
foreach (var info in disposedDeliveries)
{
this.SendDisposition(info);
}
}
if (settledCount > 0)
{
this.OnWindowMoved(settledCount);
}
}