<init>

BytePacketBuilder(
    headerSizeHint: Int = 0,
    pool: ObjectPool<ChunkBuffer>)

A builder that provides ability to build byte packets with no knowledge of it’s size. Unlike Java’s ByteArrayOutputStream it doesn’t copy the whole content every time it’s internal buffer overflows but chunks buffers instead. Packet building via build function is O(1) operation and only does instantiate a new ByteReadPacket. Once a byte packet has been built via build function call, the builder could be reused again. You also can discard all written bytes via reset or release. Please note that an instance of builder need to be terminated either via build function invocation or via release call otherwise it will cause byte buffer leak so that may have performance impact.

Byte packet builder is also an Appendable so it does append UTF-8 characters to a packet

buildPacket {
    listOf(1,2,3).joinTo(this, separator = ",")
}