ObjectPool/README.md

36 lines
1.0 KiB
Markdown
Raw Normal View History

2015-02-02 00:36:28 +01:00
ObjectPool
==========
This provides an ObjectPool factory, for providing two different types of object pools. Safe and unsafe.
2015-02-02 00:40:05 +01:00
The main distinction between this pool and others, is speed and compatibility. The factory offers two
implementations:
- https://github.com/ashkrit/blog/tree/master/FastObjectPool
- https://code.google.com/p/furious-objectpool
2015-02-08 02:36:04 +01:00
2015-02-02 00:40:05 +01:00
The faster implementation uses UNSAFE, which is unavailable on android and non-oracle JVMs, in which case the
2015-02-08 02:36:04 +01:00
fallback pool is used, which is based on a LinkedBlockingDeque.
If the list gets hot and contended, you can get scaling bugs. It gets complicated too fast and is not
worth it for small to even moderate sized objects.
Use it only for large objects.
2015-02-02 00:36:28 +01:00
- This is for cross-platform use, specifically - linux 32/64, mac 32/64, and windows 32/64. Java 6+
Usage:
```
/**
* Takes an object from the pool
*/
public ObjectPoolHolder<T> take();
/**
* Return object to the pool
*/
public void release(ObjectPoolHolder<T> object);
```