public void clear() { for (Node n = head.next; n != null; n = n.next) { Node.release(n); assert n.getRefCnt() == 0; n.clearEntry(); Node.free(n); } head.next = null; }
static Node alloc() { final int threshold = 2; int tryCnt = 0; while (true) { tryCnt++; Node n = pool.poll(); if (n == null) { return new Node(); } else { if (n.getRefCnt() > 0) { pool.add(n); if (tryCnt <= threshold) continue; else return new Node(); } else { if (n.next != null) n.next.decRefCnt(); n.init(); return n; } } } }