MCPcopy Create free account
hub / github.com/apache/tomcat / getBuffer

Method getBuffer

java/org/apache/catalina/tribes/io/BufferPool.java:72–85  ·  view source on GitHub ↗

Retrieves a buffer from the pool. @param minSize minimum buffer size @param discard discard flag @return the buffer

(int minSize, boolean discard)

Source from the content-addressed store, hash-verified

70 * @return the buffer
71 */
72 public XByteBuffer getBuffer(int minSize, boolean discard) {
73 XByteBuffer buffer = queue.poll();
74 if (buffer != null) {
75 size.addAndGet(-buffer.getCapacity());
76 }
77 if (buffer == null) {
78 buffer = new XByteBuffer(minSize, discard);
79 } else if (buffer.getCapacity() <= minSize) {
80 buffer.expand(minSize);
81 }
82 buffer.setDiscard(discard);
83 buffer.reset();
84 return buffer;
85 }
86
87 /**
88 * Returns a buffer to the pool for reuse.

Callers

nothing calls this directly

Calls 5

getCapacityMethod · 0.95
expandMethod · 0.95
setDiscardMethod · 0.95
resetMethod · 0.95
pollMethod · 0.45

Tested by

no test coverage detected