|
Pakman
|
#include <AbstractMaster.h>

Public Member Functions | |
| AbstractMaster (bool *p_program_terminated) | |
| virtual | ~AbstractMaster ()=default |
| virtual bool | isActive () const =0 |
| virtual bool | needMorePendingTasks () const =0 |
| virtual void | pushPendingTask (const std::string &input_string)=0 |
| virtual bool | finishedTasksEmpty () const =0 |
| virtual TaskHandler & | frontFinishedTask ()=0 |
| virtual void | popFinishedTask ()=0 |
| virtual void | flush ()=0 |
| virtual void | terminate ()=0 |
Static Public Member Functions | |
| static master_t | getMaster (const std::string &arg) |
| static std::string | help (master_t master) |
| static void | addLongOptions (master_t master, LongOptions &lopts) |
| static void | run (master_t master, controller_t controller, const Arguments &args) |
| static void | cleanup (master_t master) |
Protected Member Functions | |
| void | assignController (std::shared_ptr< AbstractController > p_controller) |
| virtual void | iterate ()=0 |
| bool | programTerminated () const |
Protected Attributes | |
| std::weak_ptr< AbstractController > | m_p_controller |
An abstract class for performing simulation tasks.
AbstractMasters are responsible for performing simulation tasks that it receives from an instantiation of the AbstractController class.
A simulation task consists of spawning a simulator, feeding it some input and retrieving the output. Simulation tasks are represented by the TaskHandler class.
The AbstractMaster::assignController() and AbstractController::assignMaster() methods are used for assigning AbstractMaster and AbstractController objects to each other.
AbstractMasters are designed for use in an event loop. The AbstractMaster::iterate() method should be called repeatedly until isActive() returns false. The terminate() method should be called by AbstractController when it is no longer needed.
The task processing machinery of AbstractMaster is abstracted using task queues; AbstractControllers push tasks that need to be completed with pushPendingTask() and access finished tasks using frontFinishedTask(). The AbstractMaster is responsible for popping tasks from the pending tasks queue, running the corresponding simulation and pushing finished tasks to the finished tasks queue. The finished tasks should be pushed in the same order as they were added to the pending tasks queue. The flush() method flushes all queues and discards all running simulations.
The use of AbstractMaster is governed by static methods. The static addLongOptions() and help() methods determine which command-line options the Master accepts and return a help message explaining the options, respectively. The static run() method sets up the appropriate Master and runs it in an event loop.
Definition at line 48 of file AbstractMaster.h.
| AbstractMaster::AbstractMaster | ( | bool * | p_program_terminated | ) |
Constructor saves program termination flag.
| p_program_terminated | pointer to boolean flag that is set when the execution of Pakman is terminated by the user. |
Definition at line 9 of file AbstractMaster.cc.
|
virtualdefault |
Default destructor does nothing.
|
static |
Add Master-specific long options to the given LongOptions object.
When subclassing AbstractMaster, be sure to include a static method with the signature
and add an entry in the switch statement of AbstractMaster::addLongOptions().
| master | Master type. |
| lopts | long options that the Master needs. |
Definition at line 43 of file AbstractMasterStatic.cc.
|
protected |
Assign pointer to AbstractController.
| p_controller | pointer to AbstractController object to be assigned to AbstractMaster. |
Definition at line 15 of file AbstractMaster.cc.
|
static |
Execute cleanup function based on Master type.
When subclassing AbstractMaster, be sure to include a static method with the signature
and add an entry in the switch statement of AbstractMaster::cleanup().
| master | Master type. |
Definition at line 79 of file AbstractMasterStatic.cc.
|
pure virtual |
Implemented in MPIMaster, and SerialMaster.
|
pure virtual |
Flush all finished, busy and pending tasks.
Implemented in MPIMaster, and SerialMaster.
|
pure virtual |
Implemented in MPIMaster, and SerialMaster.
|
static |
Interpret string as Master type.
The master_t enumeration type is defined in common.h.
| arg | string to be interpreted. |
Definition at line 14 of file AbstractMasterStatic.cc.
|
static |
Return help message based on Master type.
When subclassing AbstractMaster, be sure to include a static method with the signature
and add an entry in the switch statement of AbstractMaster::help().
| master | Master type. |
Definition at line 28 of file AbstractMasterStatic.cc.
|
pure virtual |
Implemented in MPIMaster, and SerialMaster.
|
protectedpure virtual |
Iterates the AbstractMaster in an event loop.
Implemented in MPIMaster, and SerialMaster.
|
pure virtual |
Implemented in MPIMaster, and SerialMaster.
|
pure virtual |
Pop front finished task.
Implemented in MPIMaster, and SerialMaster.
|
protected |
Definition at line 22 of file AbstractMaster.cc.
|
pure virtual |
Push a new pending task.
| input_string | input string to simulation job. |
Implemented in MPIMaster, and SerialMaster.
|
static |
Execute run function based on Master type.
When subclassing AbstractMaster, be sure to include a static method with the signature
and add an entry in the switch statement of AbstractMaster::run().
| master | Master type. |
| controller | Controller type. |
| args | command-line arguments. |
Definition at line 61 of file AbstractMasterStatic.cc.
|
pure virtual |
Terminate AbstractMaster.
Implemented in MPIMaster, and SerialMaster.
|
protected |
Weak pointer to AbstractController.
Definition at line 185 of file AbstractMaster.h.