public FrozenBufferedUpdates FreezeGlobalBuffer(DeleteSlice callerSlice)
{
GlobalBufferLock.@Lock();
/*
* Here we freeze the global buffer so we need to lock it, apply all
* deletes in the queue and reset the global slice to let the GC prune the
* queue.
*/
Node currentTail = Tail; // take the current tail make this local any
// Changes after this call are applied later
// and not relevant here
if (callerSlice != null)
{
// Update the callers slices so we are on the same page
callerSlice.SliceTail = currentTail;
}
try
{
if (GlobalSlice.SliceTail != currentTail)
{
GlobalSlice.SliceTail = currentTail;
GlobalSlice.Apply(GlobalBufferedUpdates, BufferedUpdates.MAX_INT);
}
FrozenBufferedUpdates packet = new FrozenBufferedUpdates(GlobalBufferedUpdates, false);
GlobalBufferedUpdates.Clear();
return packet;
}
finally
{
GlobalBufferLock.Unlock();
}
}