/** * Returns a {@link Buffer} instance. If the thread local instance is consumed already * then return it. Otherwise, return an new `Buffer` instance * * @return a `Buffer` instance as described above */ public static Buffer buffer() { Buffer sb = _buf.get(); if (!sb.consumed() || sb.capacity() > BUFFER_RETENTION_LIMIT) { sb = new Buffer(BUFFER_INIT_SIZE); _buf.set(sb); return sb; } sb.reset(); return sb; }
/** * Returns a {@link Buffer} instance. If the thread local instance is consumed already * then return it. Otherwise, return an new `Buffer` instance * * @return a `Buffer` instance as described above */ public static Buffer buffer() { Buffer sb = _buf.get(); if (!sb.consumed() || sb.capacity() > BUFFER_RETENTION_LIMIT) { sb = new Buffer(BUFFER_INIT_SIZE); _buf.set(sb); return sb; } sb.reset(); return sb; }