/** * @param cacheCtx Cache context. * @param cand Cache lock candidate to add. * @return {@code True} if added as a result of this operation, {@code false} if was previously * added. */ public boolean addNext(GridCacheContext cacheCtx, GridCacheMvccCandidate cand) { assert cand != null; assert !cand.reentry() : "Lock reentries should not be linked: " + cand; // Don't order near candidates by thread as they will be ordered on // DHT node. Also, if candidate is implicit, no point to order him. if (cacheCtx.isNear() || cand.singleImplicit()) return true; LinkedList<GridCacheMvccCandidate> queue = pending.get(); GridCacheMvccCandidate prev = null; if (!queue.isEmpty()) prev = queue.getLast(); queue.add(cand); if (prev != null) { prev.next(cand); cand.previous(prev); } if (log.isDebugEnabled()) log.debug("Linked new candidate: " + cand); return true; }