git-svn-id: https://svn.microneil.com/svn/SNF4CGP/trunk@20 59e8e3e7-56fa-483b-b4b4-fa6ab0af3dfcmaster
@@ -37,6 +37,10 @@ Job& Worker::myJob() { | |||
return(*myJob_); | |||
} | |||
void Worker::clearJob() { // Forget about the job. | |||
myJob_ = 0; | |||
} | |||
LogicCheck CheckForOneJobAtATime("Worker::doJob() Check(false == isJob())"); | |||
void Worker::doJob(Job& J) { // Give this worker a job to do. | |||
@@ -62,6 +66,7 @@ bool Worker::doWork() { | |||
ScopeMutex CallTheBall(Busy); // We're busy - don't touch. | |||
if(isJob()) { // Only do a job if we have one. | |||
myJob().doIt(); | |||
clearJob(); | |||
return true; | |||
} | |||
return false; |
@@ -31,6 +31,7 @@ class Worker : private Thread { | |||
Job* myJob_; // The job to do (or 0 to stop). | |||
bool isJob(); // Job pointer check. | |||
Job& myJob(); // Safe access to myJob. | |||
void clearJob(); // Forget done jobs. | |||
public: | |||
Worker(WorkerPool& W); // Initialize and start the thread. |