17#ifndef _DECAF_UTIL_CONCURRENT_THREADPOOLEXECUTOR_H_
18#define _DECAF_UTIL_CONCURRENT_THREADPOOLEXECUTOR_H_
38 using decaf::lang::Pointer;
61 ThreadPoolExecutor(
const ThreadPoolExecutor& );
62 ThreadPoolExecutor& operator= (
const ThreadPoolExecutor& );
98 long long keepAliveTime,
const TimeUnit& unit,
132 long long keepAliveTime,
const TimeUnit& unit,
167 long long keepAliveTime,
const TimeUnit& unit,
206 long long keepAliveTime,
const TimeUnit& unit,
547 if (executer->isShutdown()) {
Definition Exception.h:38
Interface for a runnable object - defines a task that can be run by a thread.
Definition Runnable.h:29
virtual void run()=0
Run method - called by the Thread class in the context of the thread.
A Thread is a concurrent unit of execution.
Definition Thread.h:64
This class represents an error that has occurred.
Definition Throwable.h:44
Definition ArrayList.h:39
AbstractExecutorService()
A decaf::util::Queue that additionally supports operations that wait for the queue to become non-empt...
Definition BlockingQueue.h:164
Definition RejectedExecutionException.h:31
A handler for tasks that cannot be executed by a ThreadPoolExecutor.
Definition RejectedExecutionHandler.h:36
RejectedExecutionHandler()
public interface ThreadFactory
Definition ThreadFactory.h:52
AbortPolicy()
Definition ThreadPoolExecutor.h:516
virtual ~AbortPolicy()
Definition ThreadPoolExecutor.h:519
virtual void rejectedExecution(decaf::lang::Runnable *task, ThreadPoolExecutor *executer DECAF_UNUSED)
Definition ThreadPoolExecutor.h:522
virtual void rejectedExecution(decaf::lang::Runnable *task, ThreadPoolExecutor *executer DECAF_UNUSED)
Definition ThreadPoolExecutor.h:545
CallerRunsPolicy()
Definition ThreadPoolExecutor.h:539
virtual ~CallerRunsPolicy()
Definition ThreadPoolExecutor.h:542
virtual ~DiscardOldestPolicy()
Definition ThreadPoolExecutor.h:596
virtual void rejectedExecution(decaf::lang::Runnable *task, ThreadPoolExecutor *executer)
Method that may be invoked by a ThreadPoolExecutor when execute cannot accept a task.
Definition ThreadPoolExecutor.h:599
DiscardOldestPolicy()
Definition ThreadPoolExecutor.h:593
virtual void rejectedExecution(decaf::lang::Runnable *task, ThreadPoolExecutor *executer DECAF_UNUSED)
Definition ThreadPoolExecutor.h:577
DiscardPolicy()
Definition ThreadPoolExecutor.h:571
virtual ~DiscardPolicy()
Definition ThreadPoolExecutor.h:574
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 argume...
virtual int prestartAllCoreThreads()
This method will create and start new core threads running in an idle state waiting for new tasks up ...
virtual long long getTaskCount() const
Returns the current number of pending tasks in the work queue.
virtual bool allowsCoreThreadTimeout() const
Returns whether this executor has been configured to allow core threads to terminate if they sit idle...
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 th...
virtual void setMaximumPoolSize(int maxSize)
Sets the maximum number of workers this Executor is allowed to have at any given time above the core ...
ThreadPoolExecutor(int corePoolSize, int maxPoolSize, long long keepAliveTime, const TimeUnit &unit, BlockingQueue< decaf::lang::Runnable * > *workQueue)
Creates a new instance of a ThreadPoolExecutor.
virtual void onShutdown()
Used by some Decaf ThreadPoolExecutor extensions to correctly handle the shutdown case.
virtual ThreadFactory * getThreadFactory() const
Gets the currently configured ThreadFactory.
bool remove(decaf::lang::Runnable *task)
Attempts to remove the Runnable from the work queue, if successful then the caller now owns the Runna...
virtual void shutdown()
Performs an orderly shutdown of this Executor.
friend class ExecutorKernel
Definition ThreadPoolExecutor.h:66
virtual long long getCompletedTaskCount() const
Returns the approximate number of Tasks that have been completed by this Executor,...
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 sched...
virtual void allowCoreThreadTimeout(bool value)
When true this setting allows the threads in the core pool to terminate if they sit idle longer than ...
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 bool isTerminating() const
Returns true if the executor has begin the process of terminating but has not yet completed the proce...
virtual RejectedExecutionHandler * getRejectedExecutionHandler() const
Gets the currently configured RejectedExecutionHandler for this Executor.
virtual bool isShutdown() const
Returns whether this executor has been shutdown or not.
virtual void setThreadFactory(ThreadFactory *factory)
Sets the ThreadFactory instance used to create new Threads for this Executor.
virtual int getMaximumPoolSize() const
Returns the configured maximum number of threads for this Executor.
virtual void purge()
Attempts to remove any Future derived tasks from the pending work queue if they have been canceled.
virtual void setRejectedExecutionHandler(RejectedExecutionHandler *handler)
Sets the new RejectedExecutionHandler that this executor should use to process any rejected Runnable ...
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.
virtual void afterExecute(decaf::lang::Runnable *task, decaf::lang::Throwable *error)
Called upon completion of execution of a given task.
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...
virtual bool isTerminated() const
Returns whether all tasks have completed after this executor was shut down.
virtual ArrayList< decaf::lang::Runnable * > shutdownNow()
Attempts to stop all currently executing tasks and returns an ArrayList containing the Runnables that...
virtual void setCorePoolSize(int poolSize)
Set the number of threads that this executor treats as its core threads, this value will override the...
virtual bool prestartCoreThread()
By default a Core thread is only created once the first task is queued, this method forces the creati...
virtual int getLargestPoolSize() const
Returns the most Threads that have ever been active at one time within this Executors Thread pool.
virtual int getCorePoolSize() const
Returns the configured number of core threads for this Executor.
virtual BlockingQueue< decaf::lang::Runnable * > * getQueue()
Provides access to the Task Queue used by this Executor.
virtual void terminated()
Method invoked when the Executor has terminated, by default this method does nothing.
virtual ~ThreadPoolExecutor()
virtual void beforeExecute(decaf::lang::Thread *thread, decaf::lang::Runnable *task)
Method called before a task is executed by the given thread.
virtual int getActiveCount() const
Returns an approximation of the number of threads that are currently running tasks for this executor.
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.
virtual int getPoolSize() const
Returns the number of threads that currently exists for this Executor.
virtual void execute(decaf::lang::Runnable *task, bool takeOwnership)
Executes the given command at some time in the future.
A TimeUnit represents time durations at a given unit of granularity and provides utility methods to c...
Definition TimeUnit.h:62
#define NULL
Definition Config.h:33
#define DECAF_API
Definition Config.h:29
Definition AbstractExecutorService.h:28
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25