{"id":15044850,"url":"https://github.com/jhg023/pbbl","last_synced_at":"2025-04-10T00:43:03.684Z","repository":{"id":57720494,"uuid":"172263434","full_name":"jhg023/Pbbl","owner":"jhg023","description":"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.","archived":false,"fork":false,"pushed_at":"2020-05-25T20:13:41.000Z","size":18,"stargazers_count":38,"open_issues_count":0,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T00:42:57.348Z","etag":null,"topics":["byte","bytebuffer","bytes","java","java-11","pool","pooling"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jhg023.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-23T20:59:48.000Z","updated_at":"2024-09-28T06:51:28.000Z","dependencies_parsed_at":"2022-09-26T21:41:15.770Z","dependency_job_id":null,"html_url":"https://github.com/jhg023/Pbbl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhg023%2FPbbl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhg023%2FPbbl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhg023%2FPbbl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhg023%2FPbbl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhg023","download_url":"https://codeload.github.com/jhg023/Pbbl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137998,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["byte","bytebuffer","bytes","java","java-11","pool","pooling"],"created_at":"2024-09-24T20:51:08.173Z","updated_at":"2025-04-10T00:43:03.662Z","avatar_url":"https://github.com/jhg023.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pbbl (pr. _pebble_, pɛbəl)\nA thread-safe [Buffer](https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/nio/Buffer.html) pool that allows for the automatic reuse of `Buffer` objects (including [`ByteBuffer`](https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/nio/ByteBuffer.html), [`CharBuffer`](https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/nio/CharBuffer.html), etc.), which can be over 30x faster than having to allocate a new `Buffer`.\n\n# Maven/Gradle Dependency\n 1. Add Pbbl as a dependency using either Maven or Gradle:\n\nMaven:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.jhg023\u003c/groupId\u003e\n  \u003cartifactId\u003ePbbl\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\nGradle:\n```groovy\nimplementation 'com.github.jhg023:Pbbl:1.0.2'\n```\n\n 2. Because Pbbl is compiled with Java 11, you must require its module in your `module-info.java`:\n\n```java\nmodule my.project {\n    requires com.github.pbbl;\n}\n```\n\n# Example(s)\n1. Create `ByteBufferPool` and manually close it:\n```java\n// Create a ByteBufferPool (used to pool non-direct ByteBuffer objects).\nvar pool = new ByteBufferPool();\n\n// Take a non-direct ByteBuffer (with 8 available bytes) from the pool.\n// If the pool is empty, a new ByteBuffer will be created.\nvar buffer = pool.take(Long.BYTES);\n\n// Do something with the ByteBuffer.\nvar array = buffer.putLong(42).array();\n\n// Give the ByteBuffer back to the pool for re-use.\npool.give(buffer);\n\n// Close the pool when finished.\npool.close();\n```\n2. Create `DirectFloatBufferPool` and automatically close it:\n```java\n// Create a DirectFloatBufferPool (used to pool direct FloatBuffer objects).\ntry (var pool = new DirectFloatBufferPool()) {\n    // Take a direct FloatBuffer (with 8 available floats) from the pool.\n    FloatBuffer buffer = pool.take(8);\n    \n    // Do something with the FloatBuffer.\n    buffer.put(42f);\n    \n    // Give the FloatBuffer back to the pool for re-use.\n    pool.give(buffer);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhg023%2Fpbbl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhg023%2Fpbbl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhg023%2Fpbbl/lists"}