@Test public void createPoolAndCheckoutTest() throws Exception { TuplePool<Long> pool = new TuplePool<>(10, false, new Loader<Long>() { @Override public Long[] createArray(int size) throws Exception { Long[] ary = new Long[size]; for (int i=0; i<ary.length; i++) { ary[i] = 0L; } return ary; } }, new Destroyer<Long>() { @Override public void destroyArray(Long[] ary) { } } ); for (int i=0; i<10; i++) { Long n = pool.checkout(); assertEquals(new Long(0L), n); } exception.expect(IllegalStateException.class); pool.checkout(); }
public T checkout() { ArrayDeque<T> deque = pool.get(); possiblyReload(deque); T obj = deque.pop(); initialize(obj); return obj; }
TuplePool { public T checkout() { ArrayDeque<T> deque = pool.get(); possiblyReload(deque); T obj = deque.pop(); initialize(obj); return obj; } }
TuplePool { public T checkout() { ArrayDeque<T> deque = pool.get(); possiblyReload(deque); T obj = deque.pop(); initialize(obj); return obj; } TuplePool(int size,
                     boolean createWhenExhausted,
                     Loader<T> loader,
                     Destroyer<T> destroyer);  TuplePool(final int size,
                     boolean createWhenExhausted,
                     Loader<T> loader,
                     Destroyer<T> destroyer,
                     Function<T,Void> initializer); }
TuplePool { public T checkout() { ArrayDeque<T> deque = pool.get(); possiblyReload(deque); T obj = deque.pop(); initialize(obj); return obj; } TuplePool(int size,
                     boolean createWhenExhausted,
                     Loader<T> loader,
                     Destroyer<T> destroyer);  TuplePool(final int size,
                     boolean createWhenExhausted,
                     Loader<T> loader,
                     Destroyer<T> destroyer,
                     Function<T,Void> initializer); T checkout(); void release(T obj); int getSize(); void close(); }
TuplePool { public T checkout() { ArrayDeque<T> deque = pool.get(); possiblyReload(deque); T obj = deque.pop(); initialize(obj); return obj; } TuplePool(int size,
                     boolean createWhenExhausted,
                     Loader<T> loader,
                     Destroyer<T> destroyer);  TuplePool(final int size,
                     boolean createWhenExhausted,
                     Loader<T> loader,
                     Destroyer<T> destroyer,
                     Function<T,Void> initializer); T checkout(); void release(T obj); int getSize(); void close();  }