Package io.atomix.utils.concurrent
Class ReferencePool<T extends ReferenceCounted<?>>
- java.lang.Object
-
- io.atomix.utils.concurrent.ReferencePool<T>
-
- All Implemented Interfaces:
ReferenceManager<T>,AutoCloseable
public class ReferencePool<T extends ReferenceCounted<?>> extends Object implements ReferenceManager<T>, AutoCloseable
Pool of reference counted objects.- Author:
- Jordan Halterman
-
-
Constructor Summary
Constructors Constructor Description ReferencePool(ReferenceFactory<T> factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tacquire()Acquires a reference.voidclose()voidrelease(T reference)Releases the given reference.
-
-
-
Constructor Detail
-
ReferencePool
public ReferencePool(ReferenceFactory<T> factory)
-
-
Method Detail
-
acquire
public T acquire()
Acquires a reference.- Returns:
- The acquired reference.
-
release
public void release(T reference)
Description copied from interface:ReferenceManagerReleases the given reference.This method should be called with a
ReferenceCountedobject that contains no additional references. This allows, for instance, pools to recycle dereferenced objects.- Specified by:
releasein interfaceReferenceManager<T extends ReferenceCounted<?>>- Parameters:
reference- The reference to release.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
-