|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.qpid.pool.ReferenceCountingExecutorService
public class ReferenceCountingExecutorService
ReferenceCountingExecutorService wraps an ExecutorService in order to provide shared reference to it. It counts the references taken, instantiating the service on the first reference, and shutting it down when the last reference is released.
It is important to ensure that an executor service is correctly shut down as failing to do so prevents the JVM from terminating due to the existence of non-daemon threads.Shutdown the executor service when not needed. | ExecutorService
|
Track references to the executor service. | |
Provide configuration of the executor service. |
_poolSize
should be static?, The getPool()
method breaks the encapsulation of the reference counter. Generally when getPool is used
further checks are applied to ensure that the exector service has not been shutdown. This passes responsibility
for managing the lifecycle of the reference counted object onto the caller rather than neatly encapsulating it
here. Could think about adding more state to the lifecycle, to mark ref counted objects as invalid, and have an
isValid method, or could make calling code deal with RejectedExecutionException raised by shutdown executors.Method Summary | |
---|---|
ExecutorService |
acquireExecutorService()
Provides a reference to a shared executor service, incrementing the reference count. |
static ReferenceCountingExecutorService |
getInstance()
Retrieves the singleton instance of this reference counter. |
ExecutorService |
getPool()
Provides access to the executor service, without touching the reference count. |
int |
getReferenceCount()
Return the ReferenceCount to this ExecutorService |
void |
releaseExecutorService()
Releases a reference to a shared executor service, decrementing the reference count. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ReferenceCountingExecutorService getInstance()
public ExecutorService acquireExecutorService()
public void releaseExecutorService()
public ExecutorService getPool()
public int getReferenceCount()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |