activemq-cpp-3.6.0
decaf::util::concurrent::ThreadPoolExecutor Class Reference

Defines a Thread Pool object that implements the functionality of pooling threads to perform user tasks. More...

#include <src/main/decaf/util/concurrent/ThreadPoolExecutor.h>

Inheritance diagram for decaf::util::concurrent::ThreadPoolExecutor:

Data Structures

class  AbortPolicy
 Handler policy for tasks that are rejected upon a call to ThreadPoolExecutor::execute this class always throws a RejectedExecutionException. More...
class  CallerRunsPolicy
 Handler policy for tasks that are rejected upon a call to ThreadPoolExecutor::execute this class will attempt to run the task in the Thread that called the execute method unless the executor is shutdown in which case the task is not run and is destroyed. More...
class  DiscardOldestPolicy
 Handler policy for tasks that are rejected upon a call to ThreadPoolExecutor::execute this class always destroys the oldest unexecuted task in the Queue and then attempts to execute the rejected task using the passed in executor. More...
class  DiscardPolicy
 Handler policy for tasks that are rejected upon a call to ThreadPoolExecutor::execute this class always destroys the rejected task and returns quietly. More...

Public Member Functions

 ThreadPoolExecutor (int corePoolSize, int maxPoolSize, long long keepAliveTime, const TimeUnit &unit, BlockingQueue< decaf::lang::Runnable * > *workQueue)
 Creates a new instance of a ThreadPoolExecutor.
 ThreadPoolExecutor (int corePoolSize, int maxPoolSize, long long keepAliveTime, const TimeUnit &unit, BlockingQueue< decaf::lang::Runnable * > *workQueue, RejectedExecutionHandler *handler)
 Creates a new instance of a ThreadPoolExecutor.
 ThreadPoolExecutor (int corePoolSize, int maxPoolSize, long long keepAliveTime, const TimeUnit &unit, BlockingQueue< decaf::lang::Runnable * > *workQueue, ThreadFactory *threadFactory)
 Creates a new instance of a ThreadPoolExecutor.
 ThreadPoolExecutor (int corePoolSize, int maxPoolSize, long long keepAliveTime, const TimeUnit &unit, BlockingQueue< decaf::lang::Runnable * > *workQueue, ThreadFactory *threadFactory, RejectedExecutionHandler *handler)
 Creates a new instance of a ThreadPoolExecutor.
virtual ~ThreadPoolExecutor ()
virtual void execute (decaf::lang::Runnable *task)
 This method is the same as calling the two param execute method and passing true as the second argument.
virtual void execute (decaf::lang::Runnable *task, bool takeOwnership)
 Executes the given command at some time in the future.
virtual void shutdown ()
 Performs an orderly shutdown of this Executor.
virtual ArrayList
< decaf::lang::Runnable * > 
shutdownNow ()
 Attempts to stop all currently executing tasks and returns an ArrayList containing the Runnables that did not get executed, these object become the property of the caller and are not deleted by this class, they are removed from the work queue and forgotten about.
virtual bool awaitTermination (long long timeout, const decaf::util::concurrent::TimeUnit &unit)
 The caller will block until the executor has completed termination meaning all tasks that where scheduled before shutdown have now completed and the executor is ready for deletion.
virtual bool isShutdown () const
 Returns whether this executor has been shutdown or not.
virtual bool isTerminated () const
 Returns whether all tasks have completed after this executor was shut down.
virtual int getPoolSize () const
 Returns the number of threads that currently exists for this Executor.
virtual int getCorePoolSize () const
 Returns the configured number of core threads for this Executor.
virtual void setCorePoolSize (int poolSize)
 Set the number of threads that this executor treats as its core threads, this value will override the value set in the constructor.
virtual int getMaximumPoolSize () const
 Returns the configured maximum number of threads for this Executor.
virtual void setMaximumPoolSize (int maxSize)
 Sets the maximum number of workers this Executor is allowed to have at any given time above the core pool size.
virtual long long getTaskCount () const
 Returns the current number of pending tasks in the work queue.
virtual int getActiveCount () const
 Returns an approximation of the number of threads that are currently running tasks for this executor.
virtual long long getCompletedTaskCount () const
 Returns the approximate number of Tasks that have been completed by this Executor, this value never decreases.
virtual int getLargestPoolSize () const
 Returns the most Threads that have ever been active at one time within this Executors Thread pool.
virtual BlockingQueue
< decaf::lang::Runnable * > * 
getQueue ()
 Provides access to the Task Queue used by this Executor.
virtual bool isTerminating () const
 Returns true if the executor has begin the process of terminating but has not yet completed the process of shutting down all worker threads.
virtual void allowCoreThreadTimeout (bool value)
 When true this setting allows the threads in the core pool to terminate if they sit idle longer than the set keep alive time.
virtual bool allowsCoreThreadTimeout () const
 Returns whether this executor has been configured to allow core threads to terminate if they sit idle longer than the configured keep alive time.
virtual long long getKeepAliveTime (const TimeUnit &unit) const
 Returns the currently set value for the maximum amount of time a worker Thread that is not part of the core threads is allowed to sit idle before it terminates.
virtual void setKeepAliveTime (long long timeout, const TimeUnit &unit)
 Configures the amount of time a non core Thread will remain alive after it has completed its assigned task.
virtual void setThreadFactory (ThreadFactory *factory)
 Sets the ThreadFactory instance used to create new Threads for this Executor.
virtual ThreadFactorygetThreadFactory () const
 Gets the currently configured ThreadFactory.
virtual RejectedExecutionHandlergetRejectedExecutionHandler () const
 Gets the currently configured RejectedExecutionHandler for this Executor.
virtual void setRejectedExecutionHandler (RejectedExecutionHandler *handler)
 Sets the new RejectedExecutionHandler that this executor should use to process any rejected Runnable tasks.
virtual bool prestartCoreThread ()
 By default a Core thread is only created once the first task is queued, this method forces the creation of core thread that waits in an idle mode for new work to be enqueued.
virtual int prestartAllCoreThreads ()
 This method will create and start new core threads running in an idle state waiting for new tasks up to the set core thread limit.
bool remove (decaf::lang::Runnable *task)
 Attempts to remove the Runnable from the work queue, if successful then the caller now owns the Runnable and is responsible for deleting it.
virtual void purge ()
 Attempts to remove any Future derived tasks from the pending work queue if they have been canceled.
- Public Member Functions inherited from decaf::util::concurrent::AbstractExecutorService
 AbstractExecutorService ()
virtual ~AbstractExecutorService ()
- Public Member Functions inherited from decaf::util::concurrent::ExecutorService
virtual ~ExecutorService ()
template<typename E >
Future< E > * submit (Callable< E > *task, bool takeOwnership=true)
 Submits a value-returning task for execution and returns a Future pointer representing the pending results of the task.
template<typename E >
Future< E > * submit (decaf::lang::Runnable *task, const E &result, bool takeOwnership=true)
 Submits a Runnable task for execution and returns a Future representing that task.
template<typename E >
Future< E > * submit (decaf::lang::Runnable *task, bool takeOwnership=true)
 Submits a Runnable object for execution.
- Public Member Functions inherited from decaf::util::concurrent::Executor
virtual ~Executor ()

Protected Member Functions

virtual void beforeExecute (decaf::lang::Thread *thread, decaf::lang::Runnable *task)
 Method called before a task is executed by the given thread.
virtual void afterExecute (decaf::lang::Runnable *task, decaf::lang::Throwable *error)
 Called upon completion of execution of a given task.
virtual void terminated ()
 Method invoked when the Executor has terminated, by default this method does nothing.
virtual void onShutdown ()
 Used by some Decaf ThreadPoolExecutor extensions to correctly handle the shutdown case.
- Protected Member Functions inherited from decaf::util::concurrent::AbstractExecutorService
virtual void doSubmit (FutureType *future)
 Perform the actual submit of a FutureType instance, the caller is responsible for creating the properly typed Future<E> object and returning that to its caller.

Friends

class ExecutorKernel

Detailed Description

Defines a Thread Pool object that implements the functionality of pooling threads to perform user tasks.

The Thread Poll has max size that it will grow to. The thread pool allocates threads in blocks. When there are no waiting worker threads and a task is queued then a new batch is allocated. The user can specify the size of the blocks, otherwise a default value is used.

When the user queues a task they must also queue a listener to be notified when the task has completed, this provides the user with a mechanism to know when a task object can be freed.

To have the Thread Pool perform a task, the user enqueue's an object that implements the Runnable interface and one of the worker threads will executing it in its thread context.

Constructor & Destructor Documentation

decaf::util::concurrent::ThreadPoolExecutor::ThreadPoolExecutor ( int  corePoolSize,
int  maxPoolSize,
long long  keepAliveTime,
const TimeUnit unit,
BlockingQueue< decaf::lang::Runnable * > *  workQueue 
)

Creates a new instance of a ThreadPoolExecutor.

The executor instance is configured with the passed in parameters and a default thread Factory is used along with a default rejected execution handler.

Parameters
corePoolSizeThe number of threads to pool regardless of their idle state.
maxPoolSizeThe maximum number of threads that will ever exist at one time in the pool.
keepAliveTimeThe maximum time to keep a thread in the pool for if the number of current threads exceeds to core pool size.
unitThe units that the keepAliveTime is specified in.
workQueueA BlockingQueue implementation that will be used to hold Runnable tasks that are awaiting execution within this executor. The Executor takes ownership of the BlockingQueue instance passed once this method returns.
Exceptions
IllegalArguementExceptionif the corePoolSize or keepAliveTime are negative or the or if maximumPoolSize is less than or equal to zero, or if corePoolSize is greater than maximumPoolSize.
NullPointerExceptionif the workQueue pointer is NULL.
decaf::util::concurrent::ThreadPoolExecutor::ThreadPoolExecutor ( int  corePoolSize,
int  maxPoolSize,
long long  keepAliveTime,
const TimeUnit unit,
BlockingQueue< decaf::lang::Runnable * > *  workQueue,
RejectedExecutionHandler handler 
)

Creates a new instance of a ThreadPoolExecutor.

The executor instance is configured with the passed in parameters and a default thread Factory is used along with a default rejected execution handler.

Parameters
corePoolSizeThe number of threads to pool regardless of their idle state.
maxPoolSizeThe maximum number of threads that will ever exist at one time in the pool.
keepAliveTimeThe maximum time to keep a thread in the pool for if the number of current threads exceeds to core pool size.
unitThe units that the keepAliveTime is specified in.
workQueueA BlockingQueue implementation that will be used to hold Runnable tasks that are awaiting execution within this executor. The Executor takes ownership of the BlockingQueue instance passed once this method returns.
handlerA RejectedExecutionHandler implementation that will be used to handle any rejected tasks when they are submitted to this executor. The Executor takes ownership of the RejectedExecutionHandler instance passed once this method returns.
Exceptions
IllegalArguementExceptionif the corePoolSize or keepAliveTime are negative or the or if maximumPoolSize is less than or equal to zero, or if corePoolSize is greater than maximumPoolSize.
NullPointerExceptionif the workQueue pointer is NULL.
decaf::util::concurrent::ThreadPoolExecutor::ThreadPoolExecutor ( int  corePoolSize,
int  maxPoolSize,
long long  keepAliveTime,
const TimeUnit unit,
BlockingQueue< decaf::lang::Runnable * > *  workQueue,
ThreadFactory threadFactory 
)

Creates a new instance of a ThreadPoolExecutor.

The executor instance is configured with the passed in parameters and a default thread Factory is used along with a default rejected execution handler.

Parameters
corePoolSizeThe number of threads to pool regardless of their idle state.
maxPoolSizeThe maximum number of threads that will ever exist at one time in the pool.
keepAliveTimeThe maximum time to keep a thread in the pool for if the number of current threads exceeds to core pool size.
unitThe units that the keepAliveTime is specified in.
workQueueA BlockingQueue implementation that will be used to hold Runnable tasks that are awaiting execution within this executor. The Executor takes ownership of the BlockingQueue instance passed once this method returns.
threadFactoryA ThreadFactory implementation that will be used to create worker threads that are used by this executor to run the submitted tasks. The Executor takes ownership of the ThreadFactory instance passed once this method returns.
Exceptions
IllegalArguementExceptionif the corePoolSize or keepAliveTime are negative or the or if maximumPoolSize is less than or equal to zero, or if corePoolSize is greater than maximumPoolSize.
NullPointerExceptionif the workQueue pointer is NULL.
decaf::util::concurrent::ThreadPoolExecutor::ThreadPoolExecutor ( int  corePoolSize,
int  maxPoolSize,
long long  keepAliveTime,
const TimeUnit unit,
BlockingQueue< decaf::lang::Runnable * > *  workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler 
)

Creates a new instance of a ThreadPoolExecutor.

The executor instance is configured with the passed in parameters and a default thread Factory is used along with a default rejected execution handler.

Parameters
corePoolSizeThe number of threads to pool regardless of their idle state.
maxPoolSizeThe maximum number of threads that will ever exist at one time in the pool.
keepAliveTimeThe maximum time to keep a thread in the pool for if the number of current threads exceeds to core pool size.
unitThe units that the keepAliveTime is specified in.
workQueueA BlockingQueue implementation that will be used to hold Runnable tasks that are awaiting execution within this executor. The Executor takes ownership of the BlockingQueue instance passed once this method returns.
threadFactoryA ThreadFactory implementation that will be used to create worker threads that are used by this executor to run the submitted tasks. The Executor takes ownership of the ThreadFactory instance passed once this method returns.
handlerA RejectedExecutionHandler implementation that will be used to handle any rejected tasks when they are submitted to this executor. The Executor takes ownership of the BlockingQueue instance passed once this method returns.
Exceptions
IllegalArguementExceptionif the corePoolSize or keepAliveTime are negative or the or if maximumPoolSize is less than or equal to zero, or if corePoolSize is greater than maximumPoolSize.
NullPointerExceptionif the workQueue pointer is NULL.
virtual decaf::util::concurrent::ThreadPoolExecutor::~ThreadPoolExecutor ( )
virtual

Member Function Documentation

virtual void decaf::util::concurrent::ThreadPoolExecutor::afterExecute ( decaf::lang::Runnable task,
decaf::lang::Throwable error 
)
protectedvirtual

Called upon completion of execution of a given task.

This method is called from the Thread that executed the given Runnable. If the Throwable pointer is not NULL then its value is the Exception that caused the task to terminate.

The base class implementation does nothing, a derived class should call this method on its base class to ensure that all subclasses have a chance to process the afterExecute event.

Parameters
taskThe Runnable instance that was executed by the calling Thread.
errorThe exception that was thrown from the given Runnable.
virtual void decaf::util::concurrent::ThreadPoolExecutor::allowCoreThreadTimeout ( bool  value)
virtual

When true this setting allows the threads in the core pool to terminate if they sit idle longer than the set keep alive time.

Core threads that terminate are replaced as needed by new ones on demand. This settings requires that the set keep alive time be greater than zero and will throw an IllegalArguementException if that is not the case.

Parameters
valueBoolean value indicating if core threads are allowed to time out when idle.
Exceptions
IllegalArgumentExceptionif the keep alive time is set to zero.
virtual bool decaf::util::concurrent::ThreadPoolExecutor::allowsCoreThreadTimeout ( ) const
virtual

Returns whether this executor has been configured to allow core threads to terminate if they sit idle longer than the configured keep alive time.

Threads that are not core threads continue to time out using the set keep alive value regardless of whether this option is enabled.

Returns
true if core threads can timeout when idle.
virtual bool decaf::util::concurrent::ThreadPoolExecutor::awaitTermination ( long long  timeout,
const decaf::util::concurrent::TimeUnit unit 
)
virtual

The caller will block until the executor has completed termination meaning all tasks that where scheduled before shutdown have now completed and the executor is ready for deletion.

If the timeout period elapses before the executor reaches the terminated state then this method return false to indicate it has not terminated.

Parameters
timeoutThe amount of time to wait before abandoning the wait for termination.
unitThe unit of time that the timeout value represents.
Returns
true if the executor terminated or false if the timeout expired.
Exceptions
InterruptedExceptionif this call is interrupted while awaiting termination.

Implements decaf::util::concurrent::ExecutorService.

virtual void decaf::util::concurrent::ThreadPoolExecutor::beforeExecute ( decaf::lang::Thread thread,
decaf::lang::Runnable task 
)
protectedvirtual

Method called before a task is executed by the given thread.

The default implementation of this method does nothing, however a subclass can override this method to add some new functionality.

It is recommended that a subclass call this method on its base class to ensure that all base classes have a chance to process this event.

Parameters
threadThe thread that will be executing the given task.
taskThe task that will be executed by the given thread.
virtual void decaf::util::concurrent::ThreadPoolExecutor::execute ( decaf::lang::Runnable command)
virtual

This method is the same as calling the two param execute method and passing true as the second argument.

Parameters
commandThe runnable task to be executed.
Exceptions
RejectedExecutionExceptionif this task cannot be accepted for execution.
NullPointerExceptionif command is null

Implements decaf::util::concurrent::Executor.

Referenced by decaf::util::concurrent::ThreadPoolExecutor::DiscardOldestPolicy::rejectedExecution().

virtual void decaf::util::concurrent::ThreadPoolExecutor::execute ( decaf::lang::Runnable command,
bool  takeOwnership 
)
virtual

Executes the given command at some time in the future.

The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.

Parameters
commandThe runnable task to be executed.
takeOwnershipIndicates if the Executor should assume ownership of the task and delete the pointer once the task has completed.
Exceptions
RejectedExecutionExceptionif this task cannot be accepted for execution.
NullPointerExceptionif command is null

Implements decaf::util::concurrent::Executor.

virtual int decaf::util::concurrent::ThreadPoolExecutor::getActiveCount ( ) const
virtual

Returns an approximation of the number of threads that are currently running tasks for this executor.

This value can change rapidly.

Returns
the number of currently active threads.
virtual long long decaf::util::concurrent::ThreadPoolExecutor::getCompletedTaskCount ( ) const
virtual

Returns the approximate number of Tasks that have been completed by this Executor, this value never decreases.

Returns
the number of completed tasks since creation of the Executor.
virtual int decaf::util::concurrent::ThreadPoolExecutor::getCorePoolSize ( ) const
virtual

Returns the configured number of core threads for this Executor.

Returns
the configured number of core Threads.
virtual long long decaf::util::concurrent::ThreadPoolExecutor::getKeepAliveTime ( const TimeUnit unit) const
virtual

Returns the currently set value for the maximum amount of time a worker Thread that is not part of the core threads is allowed to sit idle before it terminates.

Parameters
unitThe unit of time to return the results in.
Returns
the configure keep alive time in the requested time units.
virtual int decaf::util::concurrent::ThreadPoolExecutor::getLargestPoolSize ( ) const
virtual

Returns the most Threads that have ever been active at one time within this Executors Thread pool.

Returns
the largest number of threads ever to coexist in this executor.
virtual int decaf::util::concurrent::ThreadPoolExecutor::getMaximumPoolSize ( ) const
virtual

Returns the configured maximum number of threads for this Executor.

Returns
the configured maximum number of Threads.
virtual int decaf::util::concurrent::ThreadPoolExecutor::getPoolSize ( ) const
virtual

Returns the number of threads that currently exists for this Executor.

Returns
the configured number of Threads in the Pool.
virtual BlockingQueue<decaf::lang::Runnable*>* decaf::util::concurrent::ThreadPoolExecutor::getQueue ( )
virtual

Provides access to the Task Queue used by this Executor.

This method is meant mainly for debugging and monitoring, care should be taken when using this method. The executor continues to execute tasks from the Queue.

Returns
a pointer to the blocking queue that this executor stores future tasks in.

Referenced by decaf::util::concurrent::ThreadPoolExecutor::DiscardOldestPolicy::rejectedExecution().

virtual RejectedExecutionHandler* decaf::util::concurrent::ThreadPoolExecutor::getRejectedExecutionHandler ( ) const
virtual

Gets the currently configured RejectedExecutionHandler for this Executor.

Returns
a pointer to the current RejectedExecutionHandler.
virtual long long decaf::util::concurrent::ThreadPoolExecutor::getTaskCount ( ) const
virtual

Returns the current number of pending tasks in the work queue.

This is an approximation as the number of pending tasks can quickly changes as tasks complete and new tasks are started.

Returns
number of outstanding tasks, approximate.
virtual ThreadFactory* decaf::util::concurrent::ThreadPoolExecutor::getThreadFactory ( ) const
virtual

Gets the currently configured ThreadFactory.

It is considered a programming error to delete the pointer returned by this method.

Returns
the currently configured ThreadFactory instance used by this object.
virtual bool decaf::util::concurrent::ThreadPoolExecutor::isShutdown ( ) const
virtual

Returns whether this executor has been shutdown or not.

Returns
true if this executor has been shutdown.

Implements decaf::util::concurrent::ExecutorService.

Referenced by decaf::util::concurrent::ThreadPoolExecutor::DiscardOldestPolicy::rejectedExecution().

virtual bool decaf::util::concurrent::ThreadPoolExecutor::isTerminated ( ) const
virtual

Returns whether all tasks have completed after this executor was shut down.

Returns
true if all tasks have completed after a request to shut down was made.

Implements decaf::util::concurrent::ExecutorService.

virtual bool decaf::util::concurrent::ThreadPoolExecutor::isTerminating ( ) const
virtual

Returns true if the executor has begin the process of terminating but has not yet completed the process of shutting down all worker threads.

If the Executor does not transition from this state to terminated after some time its generally an indication that one of the submitted tasks will not complete and the executor is locked in a terminating state.

Returns
true if all tasks have completed after a request to shut down was made.
virtual void decaf::util::concurrent::ThreadPoolExecutor::onShutdown ( )
protectedvirtual

Used by some Decaf ThreadPoolExecutor extensions to correctly handle the shutdown case.

virtual int decaf::util::concurrent::ThreadPoolExecutor::prestartAllCoreThreads ( )
virtual

This method will create and start new core threads running in an idle state waiting for new tasks up to the set core thread limit.

When the limit is reached this method returns zero to indicate no more core threads can be created.

Returns
the number of core threads created, or zero if the limit has already been met.
virtual bool decaf::util::concurrent::ThreadPoolExecutor::prestartCoreThread ( )
virtual

By default a Core thread is only created once the first task is queued, this method forces the creation of core thread that waits in an idle mode for new work to be enqueued.

If the limit on core threads has already been reached then this method returns false.

Returns
true if a new core thread was added, false otherwise.
virtual void decaf::util::concurrent::ThreadPoolExecutor::purge ( )
virtual

Attempts to remove any Future derived tasks from the pending work queue if they have been canceled.

This method can be used to more quickly remove and reclaim space as canceled tasks are not run but must await a worker thread to be removed normally. Since there are multiple threads in operation its possible for this method to not remove all canceled tasks from the work queue.

bool decaf::util::concurrent::ThreadPoolExecutor::remove ( decaf::lang::Runnable task)

Attempts to remove the Runnable from the work queue, if successful then the caller now owns the Runnable and is responsible for deleting it.

Parameters
taskThe task that is to be removed from the work queue.
Returns
true if the task was removed from the Queue.
virtual void decaf::util::concurrent::ThreadPoolExecutor::setCorePoolSize ( int  poolSize)
virtual

Set the number of threads that this executor treats as its core threads, this value will override the value set in the constructor.

If the value given is less than the current value then the core threads will shrink to the new value over time. If the value is larger than the current value then new threads may be started to process currently pending tasks, otherwise they will be started as needed when new tasks arrive.

Parameters
poolSizeThe new core pool size for this executor.
Exceptions
IllegalArgumentExceptionif the pool size value is less than zero.
virtual void decaf::util::concurrent::ThreadPoolExecutor::setKeepAliveTime ( long long  timeout,
const TimeUnit unit 
)
virtual

Configures the amount of time a non core Thread will remain alive after it has completed its assigned task.

This value can also be applied to core threads if the allowCoreThreadsTimeout option is enabled.

Parameters
timeoutThe amount of time an idle worker will live before terminating.
unitThe units that the timeout is given in.
Exceptions
IllegalArgumentExceptionif allowCoreThreadsTimeout is enabled and the the timeout value given is zero, or the timeout given is negative.
virtual void decaf::util::concurrent::ThreadPoolExecutor::setMaximumPoolSize ( int  maxSize)
virtual

Sets the maximum number of workers this Executor is allowed to have at any given time above the core pool size.

This new value overrides any set in the constructor and if smaller than the current value worker threads will terminate as they complete their current tasks and become idle.

Parameters
maxSizeThe new maximum allowed worker pool size.
Exceptions
IllegalArgumentExceptionif maxSize is negative or less than core pool size.
virtual void decaf::util::concurrent::ThreadPoolExecutor::setRejectedExecutionHandler ( RejectedExecutionHandler handler)
virtual

Sets the new RejectedExecutionHandler that this executor should use to process any rejected Runnable tasks.

This executor takes ownership of the supplied pointer and will desotroy it upon termination, any previous handler is destroyed by this call.

Parameters
handlerThe new RejectedExecutionHandler instance to use.
Exceptions
NullPointerExceptionif the handler is NULL.
virtual void decaf::util::concurrent::ThreadPoolExecutor::setThreadFactory ( ThreadFactory factory)
virtual

Sets the ThreadFactory instance used to create new Threads for this Executor.

This class takes ownership of the given ThreadFactory and will destroy it upon termination or when a new ThreadFactory is set using this method.

Parameters
factoryA ThreadFactory instance used by this Executor to create new Threads.
Exceptions
NullPointerExceptionif the given factory pointer is NULL.
virtual void decaf::util::concurrent::ThreadPoolExecutor::shutdown ( )
virtual

Performs an orderly shutdown of this Executor.

Previously queued tasks are allowed to complete but no new tasks are accepted for execution. Calling this method more than once has no affect on this executor.

Implements decaf::util::concurrent::ExecutorService.

virtual ArrayList<decaf::lang::Runnable*> decaf::util::concurrent::ThreadPoolExecutor::shutdownNow ( )
virtual

Attempts to stop all currently executing tasks and returns an ArrayList containing the Runnables that did not get executed, these object become the property of the caller and are not deleted by this class, they are removed from the work queue and forgotten about.

There is no guarantee that this method will halt execution of currently executing tasks.

Returns
an ArrayList containing all Runnable instance that were still waiting to be executed by this class, call now owns those pointers.

Implements decaf::util::concurrent::ExecutorService.

virtual void decaf::util::concurrent::ThreadPoolExecutor::terminated ( )
protectedvirtual

Method invoked when the Executor has terminated, by default this method does nothing.

When overridden the subclass should call superclass::terminated to ensure that all subclasses have their terminated method invoked.

Friends And Related Function Documentation

friend class ExecutorKernel
friend

The documentation for this class was generated from the following file: