Pakman
ForkedWorkerHandler Class Reference

#include <ForkedWorkerHandler.h>

Inheritance diagram for ForkedWorkerHandler:
Collaboration diagram for ForkedWorkerHandler:

Public Member Functions

 ForkedWorkerHandler (const Command &simulator, const std::string &input_string)
 
virtual ~ForkedWorkerHandler () override
 
virtual bool isDone () override
 
- Public Member Functions inherited from AbstractWorkerHandler
 AbstractWorkerHandler (const Command &simulator, const std::string &input_string)
 
virtual ~AbstractWorkerHandler ()=default
 
std::string getOutput ()
 
int getErrorCode ()
 

Additional Inherited Members

- Protected Attributes inherited from AbstractWorkerHandler
const Command m_simulator
 
const std::string m_input_string
 
std::string m_output_buffer
 
int m_error_code = -1
 

Detailed Description

A class for representing forked Workers.

Forked Workers are spawned using a fork()exec() pattern. This is the default choice for instantiating simulators and is analogous to how SerialMaster launches simulations.

Definition at line 15 of file ForkedWorkerHandler.h.

Constructor & Destructor Documentation

◆ ForkedWorkerHandler()

ForkedWorkerHandler::ForkedWorkerHandler ( const Command simulator,
const std::string &  input_string 
)

Construct from simulator string and input string.

The constructor will fork a process whose standard input and output is redirected to a write and a read pipe, respectively.. The input string is immediately written to the write pipe.

Parameters
simulatorcommand to run simulation.
input_stringinput string to simulator.

Definition at line 15 of file ForkedWorkerHandler.cc.

◆ ~ForkedWorkerHandler()

ForkedWorkerHandler::~ForkedWorkerHandler ( )
overridevirtual

Destructor.

The destructor waits on the forked process and closes the read pipe.

Definition at line 30 of file ForkedWorkerHandler.cc.

Member Function Documentation

◆ isDone()

bool ForkedWorkerHandler::isDone ( )
overridevirtual
Returns
whether Worker has finished.

Poll read pipe for any outstanding output and check whether forked process has finished.

Implements AbstractWorkerHandler.

Definition at line 81 of file ForkedWorkerHandler.cc.


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