if (state != null) {
Lock lock = state.getHeapUpdateLock();
lock.lock();
try {
// right, now apply all updates in sequential order, until we hit a gap
HeapDelta delta = state.peekNextDelta();
if (delta == null) {
nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, sessionId, "All contiguous deltas already processed for heapId = %s", heapId);
}
while (delta != null) {
// take a copy now, so we can use it in the initial update processing later...
HeapDelta currentDelta = delta;
nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, sessionId, "Applying delta %s for heapId = %s", currentDelta.getUpdateId(), heapId);
if (currentDelta.containsHeapTermination()) {
heapSubMutationLock.lock();
try {
currentDelta.applyTo(state.getHeap().asListener());
state.popNextDelta();
nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, sessionId, "Found heap termination in delta %s for heapId = %s", currentDelta.getUpdateId(), heapId);
terminateSubscriptions(sessionId, heapId, Subscription.CloseReason.REQUESTED_BY_PUBLISHER);
delta = null;
} finally {
heapSubMutationLock.unlock();
}
} else {
currentDelta.applyTo(state.getHeap().asListener());
state.popNextDelta();
delta = state.peekNextDelta();
}
if (currentDelta.containsFirstUpdate()) {
nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, sessionId, "Found initial update in delta for heapId = %s", heapId);
// basically we got the first update
CountDownLatch latch = heaps.getInitialPopulationLatch(heapId);
if (latch != null) {
latch.countDown();