123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- // SNF4CGP/ExecutiveProcess.cpp
- // Copyright (C) 2009 ARM Research Labs, LLC.
- // See www.armresearch.com for more information.
-
- #include "ExecutiveProcess.hpp"
-
- #include "../SNF4CGP/CodeDweller/faults.hpp"
-
- #include <iostream>
-
- using namespace std;
-
- RuntimeCheck CheckOutputProccessorWasConstructed("ExecutiveProcess::initializeOutput() Check(0 != Output)");
- RuntimeCheck CheckOutputProcessorWasStarted("ExecutiveProcess::initializeOutput() Check(Output->isRunning())");
-
- void ExecutiveProcess::initializeOutput() {
- try { Output = new OutputProcessor(*Jobs); } catch(...) {}
- CheckOutputProcessorWasConstructed(0 != Output);
- try { Output->start() } catch(...) {}
- CheckOutputProcessorWasStarted(Output->isRunning());
- }
-
- void ExecutiveProcess::initializeJobPool() {
- }
-
- void ExecutiveProcess::initializeWorkerPool() {
- }
-
- void ExecutiveProcess::shutdownWorkerPool() {
- }
-
- void ExecutiveProcess::shutdownJobPool() {
- }
-
- void ExecutiveProcess::shutdownOutput() {
- }
-
- void ExecutiveProcess::dispatchCommand(Command& C) { // Job + Worker + Command; go!
- }
-
- ExecutiveProcess::ExecutiveProcess(string& Version, string& Config) : // Simple construction.
- VersionInfo(Version),
- ConfigInfo(Config),
- Jobs(0),
- Workers(0),
- Input(0),
- Output(0),
- QuitJobNumber(0) {}
-
- ~ExecutiveProcess::ExecutiveProcess() { // Deal with uncerimoneous shutdowns.
- }
-
- void ExecutiveProcess::doStartup() { // Startup happens in this sequence.
- initializeJobPool();
- initializeOutput();
- initializeWorkerPool();
- }
-
- void ExecutiveProcess::doProcessing() { // Command processing happens here.
- Command C;
- C.CommandType = WAKE; // Create the WAKE command to announce
- C.Data = VersionInfo; // that we are alive (and who we are)
- dispatchCommand(C); // and dispatch a job with it.
- // Then process all incoming commands:
- InputProcessor& I = *Input; // Convenient handle for input processor.
- for(;0 == QuitJobNumber;) { // Loop until we have a QUIT job.
- C = I.getCommand(); // Get a command from the input.
- if(QUIT == C.CommandType) QuitJobNumber = C.Number; // QUIT command means it's time to stop.
- else dispatchCommand(C); // Dispatch a job for all other commands.
- }
- }
-
- void ExecutiveProcess::doShutdown() { // Shutdown happens in this sequence.
- shutdownWorkerPool();
- shutdownOutput();
- shutdownJobPool();
- cout << QuitJobNumber << " OK" << endl;
- }
|