|
|
@@ -1,3 +1,42 @@ |
|
|
|
// SNF4CGP/OutputProcessor.hpp
|
|
|
|
// Copyright (C) 2009 ARM Research Labs, LLC
|
|
|
|
// See www.armresearch.com for more information.
|
|
|
|
//
|
|
|
|
// The OutputProcessor feeds responses back to CommuniGate from completed jobs
|
|
|
|
// and recycles jobs back into the JobPool. This is done in a separate thread so
|
|
|
|
// that the output stream (cout) is decoupled from the rest of the application.
|
|
|
|
// If the output stream blocks momentarily then only this thread is blocked while
|
|
|
|
// all other jobs continue to operate with full steam.
|
|
|
|
|
|
|
|
#ifndef IncludedOutputProcessor
|
|
|
|
#define IncludedOutputProcessor
|
|
|
|
|
|
|
|
#include "JobPool.hpp"
|
|
|
|
|
|
|
|
#include "../CodeDweller/threading.hpp"
|
|
|
|
|
|
|
|
class OutputProcessor : private Thread { // Process job outputs.
|
|
|
|
private:
|
|
|
|
|
|
|
|
JobPool& RecycledJobs; // Where we put our recycled jobs.
|
|
|
|
ProductionQueue<Job*> CompletedJobs; // Input queue for jobs to process.
|
|
|
|
|
|
|
|
bool isTimeToStop; // Flag for when we need to stop.
|
|
|
|
void myTask(); // Task for the thread. (my loop).
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
OutputProcessor(JobPool& J); // Constructed with the JobPool.
|
|
|
|
~OutputProcessor(); // Destructor to clean things up.
|
|
|
|
|
|
|
|
void start(); // Start processing.
|
|
|
|
void outputJob(Job* J); // Take this job and ... you know.
|
|
|
|
void stop(); // Finish off the queue and quit.
|
|
|
|
|
|
|
|
const static ThreadType Type;
|
|
|
|
const static ThreadState WaitingForJobs;
|
|
|
|
const static ThreadState PostingResponses;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|