org.codehaus.gpars

groovyx.gpars.scheduler
[Java] Class FJPool

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

public class FJPool

Represents the actors' thread pool, which performs tasks on behalf of the actors. Uses a ForkJoinPool from JSR-166y 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 DEFAULT_SHUTDOWN_TIMEOUT

private int configuredPoolSize

protected ForkJoinPool pool

 
Constructor Summary
FJPool()

FJPool(int configuredPoolSize)

Creates the pool wrapping the provided ForkJoinPool

FJPool(ForkJoinPool pool)

Creates a fork/join pool of given size.

 
Method Summary
private static ForkJoinPool createPool(int poolSize)

void execute(java.lang.Runnable task)

Retrieves the internal executor service.

protected int getConfiguredPoolSize()

ForkJoinPool getForkJoinPool()

int getPoolSize()

schedules a new task for processing with the pool

void resetDefaultSize()

void resize(int poolSize)

Resizes the thread pool to the specified value

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

DEFAULT_SHUTDOWN_TIMEOUT

private static final long DEFAULT_SHUTDOWN_TIMEOUT


configuredPoolSize

private final int configuredPoolSize


pool

protected final ForkJoinPool pool


 
Constructor Detail

FJPool

public FJPool()


FJPool

public FJPool(int configuredPoolSize)
Creates the pool wrapping the provided ForkJoinPool
Parameters:
pool - The ForkJoinPool instance to wrap


FJPool

public FJPool(ForkJoinPool pool)
Creates a fork/join pool of given size. Each thread will have the uncaught exception handler set to print the unhandled exception to standard error output.
Parameters:
poolSize - The required pool size
Returns:
The created thread pool
The newly created thread pool


 
Method Detail

createPool

private static ForkJoinPool createPool(int poolSize)


execute

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


getConfiguredPoolSize

protected final int getConfiguredPoolSize()


getForkJoinPool

public final ForkJoinPool getForkJoinPool()


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*
public final void resize(int poolSize)
Resizes the thread pool to the specified value
Parameters:
poolSize - The new pool size


shutdown

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


 

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