org.codehaus.gpars

groovyx.gpars.scheduler
[Java] Class DefaultPool

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

public class 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.

Authors:
Vaclav Pech Date: Feb 27, 2009


Field Summary
private static long SHUTDOWN_TIMEOUT

private java.util.concurrent.ThreadPoolExecutor pool

private static java.util.concurrent.atomic.AtomicLong threadCount

Sets the pool size to the default

 
Constructor Summary
DefaultPool()

DefaultPool(boolean daemon)

DefaultPool(boolean daemon, int poolSize)

Creates the pool around the given executor service

DefaultPool(java.util.concurrent.ThreadPoolExecutor pool)

 
Method Summary
private static java.util.concurrent.ThreadPoolExecutor createPool(boolean daemon, int poolSize)

protected static java.lang.String createThreadName()

Created a JVM-unique name for Actors' threads.

void execute(java.lang.Runnable task)

Retrieves the internal executor service.

java.util.concurrent.ExecutorService getExecutorService()

int getPoolSize()

schedules a new task for processing with the pool

void resetDefaultSize()

void resize(int poolSize)

void shutdown()

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

SHUTDOWN_TIMEOUT

private static final long SHUTDOWN_TIMEOUT


pool

private final java.util.concurrent.ThreadPoolExecutor pool


threadCount

private static final java.util.concurrent.atomic.AtomicLong threadCount
Sets the pool size to the default


 
Constructor Detail

DefaultPool

public DefaultPool()


DefaultPool

public DefaultPool(boolean daemon)


DefaultPool

public DefaultPool(boolean daemon, int poolSize)
Creates the pool around the given executor service
Parameters:
pool - The executor service to use


DefaultPool

public DefaultPool(java.util.concurrent.ThreadPoolExecutor pool)


 
Method Detail

createPool

private static java.util.concurrent.ThreadPoolExecutor createPool(boolean daemon, int poolSize)


createThreadName

protected static java.lang.String createThreadName()
Created a JVM-unique name for Actors' threads.
Returns:
The name prefix


execute

@java.lang.Override* Gently stops the pool
public final void execute(java.lang.Runnable task)
Retrieves the internal executor service.
Returns:
The underlying thread pool


getExecutorService

public final java.util.concurrent.ExecutorService getExecutorService()


getPoolSize

@java.lang.Override/**
public int getPoolSize()
schedules a new task for processing with the pool
Parameters:
task - The task to schedule


resetDefaultSize

@java.lang.Override/**
public final void resetDefaultSize()


resize

@java.lang.Override* Retrieves the current thread pool size
public final void resize(int poolSize)


shutdown

@java.lang.Override
public final void shutdown()


 

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