public class DefaultPool extends java.lang.Object implements Pool
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ThreadPoolExecutor |
pool |
private static long |
SHUTDOWN_TIMEOUT |
private static java.util.concurrent.atomic.AtomicLong |
threadCount
Unique counter for Actors' threads
|
POOL_SIZE_MUST_BE_A_POSITIVE_NUMBER, UNCAUGHT_EXCEPTION_OCCURRED_IN_GPARS_POOL
Constructor and Description |
---|
DefaultPool()
Creates the pool with default number of daemon threads.
|
DefaultPool(boolean daemon)
Creates the pool with default number of threads.
|
DefaultPool(boolean daemon,
int poolSize)
Creates the pool with specified number of threads.
|
DefaultPool(java.util.concurrent.ThreadPoolExecutor pool)
Creates the pool around the given executor service
|
Modifier and Type | Method and Description |
---|---|
private static java.util.concurrent.ThreadPoolExecutor |
createPool(boolean daemon,
int poolSize)
Creates a fixed-thread pool of given size.
|
protected static java.lang.String |
createThreadName()
Created a JVM-unique name for Actors' threads.
|
void |
execute(java.lang.Runnable task)
schedules a new task for processing with the pool
|
java.util.concurrent.ExecutorService |
getExecutorService()
Retrieves the internal executor service.
|
int |
getPoolSize()
Retrieves the current thread pool size
|
void |
resetDefaultSize()
Sets the pool size to the default
|
void |
resize(int poolSize)
Resizes the thread pool to the specified value
|
void |
shutdown()
Gently stops the pool
|
private final java.util.concurrent.ThreadPoolExecutor pool
private static final long SHUTDOWN_TIMEOUT
private static final java.util.concurrent.atomic.AtomicLong threadCount
public DefaultPool()
public DefaultPool(boolean daemon)
daemon
- Sets the daemon flag of threads in the pool.public DefaultPool(boolean daemon, int poolSize)
daemon
- Sets the daemon flag of threads in the pool.poolSize
- The required size of the poolpublic DefaultPool(java.util.concurrent.ThreadPoolExecutor pool)
pool
- The executor service to useprivate static java.util.concurrent.ThreadPoolExecutor createPool(boolean daemon, int poolSize)
daemon
- Sets the daemon flag of threads in the pool.poolSize
- The required pool size @return The created thread poolprotected static java.lang.String createThreadName()
public final void resize(int poolSize)
public final void resetDefaultSize()
resetDefaultSize
in interface Pool
public int getPoolSize()
getPoolSize
in interface Pool
public final void execute(java.lang.Runnable task)
public final java.util.concurrent.ExecutorService getExecutorService()