Retrieves a buffer from the pool. @param minSize minimum buffer size @param discard discard flag @return the buffer
(int minSize, boolean discard)
| 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. |
nothing calls this directly
no test coverage detected