groovyx.gpars.scheduler
Class ResizeablePool

java.lang.Object
  extended by groovyx.gpars.scheduler.DefaultPool
      extended by groovyx.gpars.scheduler.ResizeablePool
All Implemented Interfaces:
Pool

public final class ResizeablePool
extends DefaultPool

Represents the actors' thread pool, which performs tasks on behalf of the actors. The actors' thread pool size defaults to the n + 1, where n is the number of processors/cores available on the machine. The VM parameter -Dgpars.poolsize can be used the configure the default size of the actors' thread pool. The resize() and resetDefaultSize() methods can be used to configure size of the thread pool at runtime.

Author:
Vaclav Pech Date: Feb 27, 2009

Field Summary
private static long KEEP_ALIVE_TIME
           
 
Fields inherited from interface groovyx.gpars.scheduler.Pool
POOL_SIZE_MUST_BE_A_POSITIVE_NUMBER, UNCAUGHT_EXCEPTION_OCCURRED_IN_ACTOR_POOL
 
Constructor Summary
ResizeablePool(boolean daemon)
          Creates the pool with default number of threads.
ResizeablePool(boolean daemon, int poolSize)
          Creates the pool with specified number of threads.
 
Method Summary
private static java.util.concurrent.ThreadPoolExecutor createResizeablePool(boolean daemon, int poolSize)
          Creates a fixed-thread pool of given size.
 
Methods inherited from class groovyx.gpars.scheduler.DefaultPool
createThreadName, execute, getExecutorService, getPoolSize, resetDefaultSize, resize, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEEP_ALIVE_TIME

private static final long KEEP_ALIVE_TIME
See Also:
Constant Field Values
Constructor Detail

ResizeablePool

public ResizeablePool(boolean daemon)
Creates the pool with default number of threads.

Parameters:
daemon - Sets the daemon flag of threads in the pool.

ResizeablePool

public ResizeablePool(boolean daemon,
                      int poolSize)
Creates the pool with specified number of threads.

Parameters:
daemon - Sets the daemon flag of threads in the pool.
poolSize - The required size of the pool
Method Detail

createResizeablePool

private static java.util.concurrent.ThreadPoolExecutor createResizeablePool(boolean daemon,
                                                                            int poolSize)
Creates a fixed-thread pool of given size. Each thread will have the uncaught exception handler set to print the unhandled exception to standard error output.

Parameters:
daemon - Sets the daemon flag of threads in the pool.
poolSize - The required pool size @return The created thread pool
Returns:
The newly created thread pool

Copyright © 2008–2012 Václav Pech. All Rights Reserved.