$darkmode
DENOPTIM
|
Runs tasks parallel in asynchronous fashion. More...
Public Member Functions | |
ParallelAsynchronousTaskExecutor (int numberOfTasks, Logger logger) | |
Constructor. More... | |
void | stopRun () |
Stops all subtasks and shutdown executor. More... | |
void | run () throws DENOPTIMException, IOException |
Run the parallelized task. More... | |
Protected Member Functions | |
boolean | subtaskHasException () |
Looks for exceptions in the subtasks and, if any, store its reference locally to allow reporting it back from the main thread. More... | |
Throwable | getExceptionFromSubTask () |
boolean | allTasksCompleted () |
Check for completion of all subtasks. More... | |
void | submitTask (Task task, String logFilePathname) |
abstract void | createAndSubmitTasks () |
Implementations of this method must call the submitTask(Task, String) method to actually send the task to the executor and eventually start it. More... | |
abstract boolean | doPostFlightOperations () |
abstract boolean | doPreFlightOperations () |
Protected Attributes | |
final List< Object > | results |
List of object returned by completed tasks. More... | |
Package Attributes | |
final ThreadPoolExecutor | tpe |
Asynchronous tasks manager. More... | |
Private Member Functions | |
void | cleanupCompleted () |
Removes only tasks that are marked as completed. More... | |
void | cleanup () |
clean all reference to submitted tasks More... | |
Private Attributes | |
final Map< Task, Future< Object > > | futures |
Storage of references to the submitted subtasks and their future returned value. More... | |
final List< Task > | submitted |
Storage of references to the submitted subtasks. More... | |
Throwable | thrownByTask |
If any, here we stores the exception returned by a subtask. More... | |
Logger | logger |
Logger. More... | |
int | numThreads = 1 |
Numner of threads run in parallel. More... | |
Runs tasks parallel in asynchronous fashion.
Definition at line 47 of file ParallelAsynchronousTaskExecutor.java.
denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor | ( | int | numberOfTasks, |
Logger | logger | ||
) |
Constructor.
Definition at line 95 of file ParallelAsynchronousTaskExecutor.java.
References denoptim.task.ParallelAsynchronousTaskExecutor.cleanup(), denoptim.task.ParallelAsynchronousTaskExecutor.cleanupCompleted(), denoptim.task.ParallelAsynchronousTaskExecutor.futures, denoptim.task.ParallelAsynchronousTaskExecutor.logger, denoptim.task.ParallelAsynchronousTaskExecutor.numThreads, denoptim.task.ParallelAsynchronousTaskExecutor.results, denoptim.task.ParallelAsynchronousTaskExecutor.run(), denoptim.task.ParallelAsynchronousTaskExecutor.submitted, and denoptim.task.ParallelAsynchronousTaskExecutor.tpe.
|
protected |
Check for completion of all subtasks.
true
if all subtasks are completed Definition at line 213 of file ParallelAsynchronousTaskExecutor.java.
References denoptim.task.ParallelAsynchronousTaskExecutor.submitted.
|
private |
clean all reference to submitted tasks
Definition at line 356 of file ParallelAsynchronousTaskExecutor.java.
References denoptim.task.ParallelAsynchronousTaskExecutor.futures, denoptim.task.ParallelAsynchronousTaskExecutor.submitted, and denoptim.task.ParallelAsynchronousTaskExecutor.tpe.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor(), and denoptim.task.ParallelAsynchronousTaskExecutor.stopRun().
|
private |
Removes only tasks that are marked as completed.
Definition at line 322 of file ParallelAsynchronousTaskExecutor.java.
References denoptim.task.ParallelAsynchronousTaskExecutor.futures, denoptim.task.ParallelAsynchronousTaskExecutor.logger, denoptim.task.ParallelAsynchronousTaskExecutor.results, and denoptim.task.ParallelAsynchronousTaskExecutor.submitted.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor(), denoptim.task.ParallelAsynchronousTaskExecutor.run(), denoptim.task.ParallelAsynchronousTaskExecutor.stopRun(), and denoptim.task.ParallelAsynchronousTaskExecutor.submitTask().
|
abstractprotected |
Implementations of this method must call the submitTask(Task, String)
method to actually send the task to the executor and eventually start it.
Reimplemented in denoptim.fragmenter.ParallelConformerExtractionAlgorithm, and denoptim.fragmenter.ParallelFragmentationAlgorithm.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.run().
|
abstractprotected |
Reimplemented in denoptim.fragmenter.ParallelConformerExtractionAlgorithm, and denoptim.fragmenter.ParallelFragmentationAlgorithm.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.run().
|
abstractprotected |
Reimplemented in denoptim.fragmenter.ParallelConformerExtractionAlgorithm, and denoptim.fragmenter.ParallelFragmentationAlgorithm.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.run().
|
protected |
Definition at line 202 of file ParallelAsynchronousTaskExecutor.java.
References denoptim.task.ParallelAsynchronousTaskExecutor.thrownByTask.
void denoptim.task.ParallelAsynchronousTaskExecutor.run | ( | ) | throws DENOPTIMException, IOException |
Run the parallelized task.
Definition at line 233 of file ParallelAsynchronousTaskExecutor.java.
References denoptim.task.ParallelAsynchronousTaskExecutor.cleanupCompleted(), denoptim.task.ParallelAsynchronousTaskExecutor.createAndSubmitTasks(), denoptim.task.ParallelAsynchronousTaskExecutor.doPostFlightOperations(), denoptim.task.ParallelAsynchronousTaskExecutor.doPreFlightOperations(), denoptim.constants.DENOPTIMConstants.EOL, denoptim.task.ParallelAsynchronousTaskExecutor.logger, and denoptim.task.ParallelAsynchronousTaskExecutor.tpe.
Referenced by denoptim.fragmenter.ParallelFragmentationAlgorithm.doPostFlightOperations(), denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor(), and denoptim.programs.fragmenter.Fragmenter.runProgram().
void denoptim.task.ParallelAsynchronousTaskExecutor.stopRun | ( | ) |
Stops all subtasks and shutdown executor.
Definition at line 167 of file ParallelAsynchronousTaskExecutor.java.
References denoptim.task.ParallelAsynchronousTaskExecutor.cleanup(), denoptim.task.ParallelAsynchronousTaskExecutor.cleanupCompleted(), and denoptim.task.ParallelAsynchronousTaskExecutor.tpe.
Referenced by denoptim.programs.fragmenter.Fragmenter.handleThrowable().
|
protected |
Definition at line 283 of file ParallelAsynchronousTaskExecutor.java.
References denoptim.task.ParallelAsynchronousTaskExecutor.cleanupCompleted(), denoptim.task.ParallelAsynchronousTaskExecutor.futures, denoptim.task.Task.getId(), denoptim.task.ParallelAsynchronousTaskExecutor.logger, denoptim.task.ParallelAsynchronousTaskExecutor.numThreads, denoptim.task.ParallelAsynchronousTaskExecutor.submitted, and denoptim.task.ParallelAsynchronousTaskExecutor.tpe.
Referenced by denoptim.fragmenter.ParallelConformerExtractionAlgorithm.createAndSubmitTasks(), and denoptim.fragmenter.ParallelFragmentationAlgorithm.createAndSubmitTasks().
|
protected |
Looks for exceptions in the subtasks and, if any, store its reference locally to allow reporting it back from the main thread.
true
if any of the subtasks has thrown an exception Definition at line 181 of file ParallelAsynchronousTaskExecutor.java.
References denoptim.task.ParallelAsynchronousTaskExecutor.submitted, and denoptim.task.ParallelAsynchronousTaskExecutor.thrownByTask.
|
private |
Storage of references to the submitted subtasks and their future returned value.
This is cleaned up every now and then, to avoid memory leak, but we keep the object returned by the future task in the results list.
Definition at line 55 of file ParallelAsynchronousTaskExecutor.java.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.cleanup(), denoptim.task.ParallelAsynchronousTaskExecutor.cleanupCompleted(), denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor(), and denoptim.task.ParallelAsynchronousTaskExecutor.submitTask().
|
private |
Logger.
Definition at line 81 of file ParallelAsynchronousTaskExecutor.java.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.cleanupCompleted(), denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor(), denoptim.task.ParallelAsynchronousTaskExecutor.run(), and denoptim.task.ParallelAsynchronousTaskExecutor.submitTask().
|
private |
Numner of threads run in parallel.
Definition at line 86 of file ParallelAsynchronousTaskExecutor.java.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor(), and denoptim.task.ParallelAsynchronousTaskExecutor.submitTask().
|
protected |
List of object returned by completed tasks.
Definition at line 66 of file ParallelAsynchronousTaskExecutor.java.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.cleanupCompleted(), denoptim.fragmenter.ParallelFragmentationAlgorithm.doPostFlightOperations(), denoptim.fragmenter.ParallelConformerExtractionAlgorithm.getResults(), and denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor().
|
private |
Storage of references to the submitted subtasks.
This is cleaned up every now and then, to avoid memory leak.
Definition at line 61 of file ParallelAsynchronousTaskExecutor.java.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.allTasksCompleted(), denoptim.task.ParallelAsynchronousTaskExecutor.cleanup(), denoptim.task.ParallelAsynchronousTaskExecutor.cleanupCompleted(), denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor(), denoptim.task.ParallelAsynchronousTaskExecutor.submitTask(), and denoptim.task.ParallelAsynchronousTaskExecutor.subtaskHasException().
|
private |
If any, here we stores the exception returned by a subtask.
Definition at line 76 of file ParallelAsynchronousTaskExecutor.java.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.getExceptionFromSubTask(), and denoptim.task.ParallelAsynchronousTaskExecutor.subtaskHasException().
|
package |
Asynchronous tasks manager.
Definition at line 71 of file ParallelAsynchronousTaskExecutor.java.
Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.cleanup(), denoptim.task.ParallelAsynchronousTaskExecutor.ParallelAsynchronousTaskExecutor(), denoptim.task.ParallelAsynchronousTaskExecutor.run(), denoptim.task.ParallelAsynchronousTaskExecutor.stopRun(), and denoptim.task.ParallelAsynchronousTaskExecutor.submitTask().