$darkmode
DENOPTIM
denoptim.task.ParallelAsynchronousTaskExecutor Class Referenceabstract

Runs tasks parallel in asynchronous fashion. More...

Inheritance diagram for denoptim.task.ParallelAsynchronousTaskExecutor:
[legend]
Collaboration diagram for denoptim.task.ParallelAsynchronousTaskExecutor:
[legend]

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< Tasksubmitted
 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...
 

Detailed Description

Runs tasks parallel in asynchronous fashion.

Author
Marco Foscato

Definition at line 47 of file ParallelAsynchronousTaskExecutor.java.

Constructor & Destructor Documentation

◆ ParallelAsynchronousTaskExecutor()

Member Function Documentation

◆ allTasksCompleted()

boolean denoptim.task.ParallelAsynchronousTaskExecutor.allTasksCompleted ( )
protected

Check for completion of all subtasks.

Returns
true if all subtasks are completed

Definition at line 213 of file ParallelAsynchronousTaskExecutor.java.

References denoptim.task.ParallelAsynchronousTaskExecutor.submitted.

◆ cleanup()

void denoptim.task.ParallelAsynchronousTaskExecutor.cleanup ( )
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().

Here is the caller graph for this function:

◆ cleanupCompleted()

void denoptim.task.ParallelAsynchronousTaskExecutor.cleanupCompleted ( )
private

◆ createAndSubmitTasks()

abstract void denoptim.task.ParallelAsynchronousTaskExecutor.createAndSubmitTasks ( )
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().

Here is the caller graph for this function:

◆ doPostFlightOperations()

abstract boolean denoptim.task.ParallelAsynchronousTaskExecutor.doPostFlightOperations ( )
abstractprotected

Reimplemented in denoptim.fragmenter.ParallelConformerExtractionAlgorithm, and denoptim.fragmenter.ParallelFragmentationAlgorithm.

Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.run().

Here is the caller graph for this function:

◆ doPreFlightOperations()

abstract boolean denoptim.task.ParallelAsynchronousTaskExecutor.doPreFlightOperations ( )
abstractprotected

Reimplemented in denoptim.fragmenter.ParallelConformerExtractionAlgorithm, and denoptim.fragmenter.ParallelFragmentationAlgorithm.

Referenced by denoptim.task.ParallelAsynchronousTaskExecutor.run().

Here is the caller graph for this function:

◆ getExceptionFromSubTask()

Throwable denoptim.task.ParallelAsynchronousTaskExecutor.getExceptionFromSubTask ( )
protected
Returns
the trace of the problem occurred in the first subtask that was detected to have a problem.

Definition at line 202 of file ParallelAsynchronousTaskExecutor.java.

References denoptim.task.ParallelAsynchronousTaskExecutor.thrownByTask.

◆ run()

void denoptim.task.ParallelAsynchronousTaskExecutor.run ( ) throws DENOPTIMException, IOException

◆ stopRun()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ submitTask()

void denoptim.task.ParallelAsynchronousTaskExecutor.submitTask ( Task  task,
String  logFilePathname 
)
protected

◆ subtaskHasException()

boolean denoptim.task.ParallelAsynchronousTaskExecutor.subtaskHasException ( )
protected

Looks for exceptions in the subtasks and, if any, store its reference locally to allow reporting it back from the main thread.

Returns
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.

Member Data Documentation

◆ futures

final Map<Task,Future<Object> > denoptim.task.ParallelAsynchronousTaskExecutor.futures
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().

◆ logger

◆ numThreads

int denoptim.task.ParallelAsynchronousTaskExecutor.numThreads = 1
private

◆ results

◆ submitted

◆ thrownByTask

Throwable denoptim.task.ParallelAsynchronousTaskExecutor.thrownByTask
private

◆ tpe


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