Fast, lightweight, and compatible blocking/non-blocking/soft-reference object pool for Java 6+
 
 
Go to file
Robinson e01062198f
updated build deps
2023-11-27 17:14:37 +01:00
gradle/wrapper updated gradle 2023-09-06 18:46:06 +02:00
src/dorkbox/objectPool version 4.4 2023-09-06 22:02:25 +02:00
src9 Updated JPMS to use new coroutine jpms module 2023-06-07 22:42:29 +02:00
test/dorkbox/objectPool Added support for converting collections to a blocking/suspending pool 2022-06-29 16:07:54 +02:00
.gitignore Updated to use Gradle Utils for gradle/project update management 2019-05-13 15:18:33 +02:00
LICENSE Updated license 2023-01-22 23:07:14 +01:00
LICENSE.Apachev2 Initial import of ObjectPool project 2015-02-02 00:33:46 +01:00
README.md version 4.4 2023-09-06 22:02:25 +02:00
build.gradle.kts updated build deps 2023-11-27 17:14:37 +01:00
gradle.properties updated version, JPMS support 2021-05-03 14:14:37 +02:00
gradlew updated gradle 2023-09-06 18:46:06 +02:00
gradlew.bat updated gradle 2023-09-06 18:46:06 +02:00
settings.gradle.kts Hardcoded project name 2023-08-05 12:26:33 -06:00

README.md

ObjectPool

Dorkbox Github Gitlab

This provides an ObjectPool, for providing for a safe, and fixed sized pool of objects. This is only recommended in systems were garbage collection is to be kept to a minimum, and the created objects are large.

  • This is for cross-platform use, specifically - linux 32/64, mac 32/64, and windows 32/64. Java 11+

Usage:

    val <T> pool = ObjectPool.nonBlocking(PoolObject<T>() {
        /**
         * Called when an object is returned to the pool, useful for resetting an objects state, for example.
         */
         fun onReturn(`object`: Foo) {
            object.foo = 0;
            object.bar = null;
         }
    
         /**
          * Takes an object from the pool, if there is no object available, will create a new object.
          */
          fun onTake(`object`: Foo) {
          }
    
          /**
           * @return a new object instance created by the pool.
           */
          override fun newInstance(): Foo {
             return Foo();
          }
        });


    val foo = pool.take()
    pool.put(foo)

   

Maven Info

<dependencies>
    ...
    <dependency>
      <groupId>com.dorkbox</groupId>
      <artifactId>ObjectPool</artifactId>
      <version>4.4</version>
    </dependency>
</dependencies>

Gradle Info

dependencies {
    ...
    implementation "com.dorkbox:ObjectPool:4.4"
}

License

This project is © 2020 dorkbox llc, and is distributed under the terms of the Apache v2.0 License. See file "LICENSE" for further references.