public long poll() { long result; synchronized (this) { result = this.topAddr; if (result != 0L) { this.topAddr = Chunk.getNext(result); } } return result; } /**
public long computeTotalSize() { long result; long headAddr = this.topAddr; long addr; boolean concurrentModDetected; do { concurrentModDetected = false; result = 0; addr = headAddr; while (addr != 0L) { result += Chunk.getSize(addr); addr = Chunk.getNext(addr); long curHead = this.topAddr; if (curHead != headAddr) { headAddr = curHead; concurrentModDetected = true; // Someone added or removed from the stack. // So we break out of the inner loop and start // again at the new head. break; } } } while (concurrentModDetected); return result; } }
private List<MemoryBlock> getTinyFreeBlocks() { final List<MemoryBlock> value = new ArrayList<MemoryBlock>(); final SimpleMemoryAllocatorImpl sma = this.ma; for (int i = 0; i < this.tinyFreeLists.length(); i++) { if (this.tinyFreeLists.get(i) == null) continue; long addr = this.tinyFreeLists.get(i).getTopAddress(); while (addr != 0L) { value.add(new MemoryBlockNode(sma, new TinyMemoryBlock(addr, i))); addr = Chunk.getNext(addr); } } return value; } List<MemoryBlock> getAllocatedBlocks() {
public void logSizes(LogWriter lw, String msg) { long headAddr = this.topAddr; long addr; boolean concurrentModDetected; do { concurrentModDetected = false; addr = headAddr; while (addr != 0L) { int curSize = Chunk.getSize(addr); addr = Chunk.getNext(addr); long curHead = this.topAddr; if (curHead != headAddr) { headAddr = curHead; concurrentModDetected = true; // Someone added or removed from the stack. // So we break out of the inner loop and start // again at the new head. break; } // TODO construct a single log msg // that gets reset on the concurrent mad. lw.info(msg + curSize); } } while (concurrentModDetected); } public long computeTotalSize() {