Skip to content
/ Pbbl Public
forked from jhg023/Pbbl

A thread-safe ByteBuffer pool that allows for the automatic reuse of ByteBuffers, which can be over 30x faster than having to allocate a new ByteBuffer when needed.

License

Notifications You must be signed in to change notification settings

Trigary/Pbbl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pbbl (pr. pebble, pɛbəl)

A thread-safe ByteBuffer pool that allows for the automatic reuse of ByteBuffer objects, which can be over 30x faster than having to allocate a new ByteBuffer when needed.

Maven/Gradle Dependency

Maven:

<dependency>
  <groupId>com.github.jhg023</groupId>
  <artifactId>Pbbl</artifactId>
  <version>1.0.1</version>
</dependency>

Gradle:

implementation 'com.github.jhg023:Pbbl:1.0.1'

How to Use

// Create the HeapByteBufferPool (or DirectByteBufferPool).
var pool = new HeapByteBufferPool();

// Take a ByteBuffer (with 8 available bytes) from the pool.
// If the pool is empty, a new ByteBuffer will be created.
var buffer = pool.take(8);

// Do something with the ByteBuffer.
var array = buffer.putLong(42).array();

// Give the ByteBuffer back to the pool for re-use.
pool.give(buffer);

About

A thread-safe ByteBuffer pool that allows for the automatic reuse of ByteBuffers, which can be over 30x faster than having to allocate a new ByteBuffer when needed.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%