https://github.com/dorkbox/objectpool
Fast, lightweight, and compatible blocking/non-blocking/soft-reference object pool for Java 6+
https://github.com/dorkbox/objectpool
Last synced: about 1 year ago
JSON representation
Fast, lightweight, and compatible blocking/non-blocking/soft-reference object pool for Java 6+
- Host: GitHub
- URL: https://github.com/dorkbox/objectpool
- Owner: dorkbox
- License: other
- Created: 2015-02-01T23:35:32.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-11-27T16:15:11.000Z (over 2 years ago)
- Last Synced: 2025-05-13T02:54:20.733Z (about 1 year ago)
- Language: Kotlin
- Homepage:
- Size: 371 KB
- Stars: 6
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ObjectPool
==========
###### [](https://git.dorkbox.com/dorkbox/ObjectPool) [](https://github.com/dorkbox/ObjectPool) [](https://gitlab.com/dorkbox/ObjectPool)
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 pool = ObjectPool.nonBlocking(PoolObject() {
/**
* 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
---------
```
...
com.dorkbox
ObjectPool
4.4
```
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.