net.sourceforge.acelogger.execution.manager
Class BaseUtilConcurrentExecutorManager

java.lang.Object
  extended by net.sourceforge.acelogger.execution.manager.BaseExecutorManager
      extended by net.sourceforge.acelogger.execution.manager.BaseUtilConcurrentExecutorManager
All Implemented Interfaces:
ExecutorManager, Identifiable
Direct Known Subclasses:
PooledExecutorManager, QueuedExecutorManager

public abstract class BaseUtilConcurrentExecutorManager
extends BaseExecutorManager

Abstracts all common tasks for ExecutorManager based on ExecutorService.

Since:
1.0.0
Version:
1.0.0
Author:
Zardi (https://sourceforge.net/users/daniel_zardi)

Constructor Summary
BaseUtilConcurrentExecutorManager(String identifier, ExecutorService executor)
          Constructs a new BaseUtilConcurrentExecutorManager with the supplied identifier and executor service.
 
Method Summary
 boolean awaitTermination(long terminationTimeout)
          Waits the execution of pending tasks in this executor manager.
 void execute(Runnable command)
          Executes the given command within this executor.
 boolean isTerminated()
          Returns true if this executor manager has ended its execution scheduling.
 boolean orderProperShutdown()
          Orders the proper shutdown of this executor manager, this is accomplished in most of the implementations by waiting all pending tasks or a given timeout.
 List<Runnable> terminateAndRetrieveTasks()
          Terminates this executor manager, return a list of tasks that were not executed after a proper shutdown was ordered.
 
Methods inherited from class net.sourceforge.acelogger.execution.manager.BaseExecutorManager
executeAll, getIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseUtilConcurrentExecutorManager

public BaseUtilConcurrentExecutorManager(String identifier,
                                         ExecutorService executor)
Constructs a new BaseUtilConcurrentExecutorManager with the supplied identifier and executor service.

Parameters:
identifier - The string that identifies this executor manager.
executor - The ExecutorService that will be used to execute our tasks.
Since:
1.0.0
Method Detail

execute

public void execute(Runnable command)
Executes the given command within this executor. This method should block until the command execution or not, this will depend on the implementation.

Parameters:
command - The task to be executed.

isTerminated

public boolean isTerminated()
Returns true if this executor manager has ended its execution scheduling.

Returns:
True if the executor manager was shutdown; False otherwise.

orderProperShutdown

public boolean orderProperShutdown()
Orders the proper shutdown of this executor manager, this is accomplished in most of the implementations by waiting all pending tasks or a given timeout.

Returns:
True if the executor shutdown process was successful; False otherwise.

awaitTermination

public boolean awaitTermination(long terminationTimeout)
Waits the execution of pending tasks in this executor manager. This method must be called after ordering a proper shutdown.

Parameters:
terminationTimeout - The maximum time (in ms) to wait for remaining tasks to execute.
Returns:
True if the executor finished processing all of it's tasks; False if timeout was reached during the wait.
See Also:
ExecutorManager.orderProperShutdown()

terminateAndRetrieveTasks

public List<Runnable> terminateAndRetrieveTasks()
Terminates this executor manager, return a list of tasks that were not executed after a proper shutdown was ordered. This method should be called preferably after waiting for the tasks to execute.

Returns:
A list containing the tasks pending execution.
See Also:
ExecutorManager.orderProperShutdown(), ExecutorManager.awaitTermination(long)


Copyright © 2007-2010 The AceLogger Team. All Rights Reserved.