The current batch read API, GetN, creates and returns a new populated buffer on every call. This does not allow the buffer to be reused across multiple calls to GetN, and may result in GC that could be avoided by buffer reuse.
To address this, there should be a new API that takes a buffer, provided by the caller, and drains the queue into that buffer. A call to this API returns when the provided buffer is full or when there are no more items in the queue to drain.
The current batch read API,
GetN, creates and returns a new populated buffer on every call. This does not allow the buffer to be reused across multiple calls toGetN, and may result in GC that could be avoided by buffer reuse.To address this, there should be a new API that takes a buffer, provided by the caller, and drains the queue into that buffer. A call to this API returns when the provided buffer is full or when there are no more items in the queue to drain.