Browse Source

Added clearJob()

git-svn-id: https://svn.microneil.com/svn/SNF4CGP/trunk@20 59e8e3e7-56fa-483b-b4b4-fa6ab0af3dfc
master
madscientist 15 years ago
parent
commit
2111d2b112
2 changed files with 6 additions and 0 deletions
  1. 5
    0
      SNF4CGP/WorkerPool.cpp
  2. 1
    0
      SNF4CGP/WorkerPool.hpp

+ 5
- 0
SNF4CGP/WorkerPool.cpp View File

return(*myJob_); return(*myJob_);
} }
void Worker::clearJob() { // Forget about the job.
myJob_ = 0;
}
LogicCheck CheckForOneJobAtATime("Worker::doJob() Check(false == isJob())"); LogicCheck CheckForOneJobAtATime("Worker::doJob() Check(false == isJob())");
void Worker::doJob(Job& J) { // Give this worker a job to do. void Worker::doJob(Job& J) { // Give this worker a job to do.
ScopeMutex CallTheBall(Busy); // We're busy - don't touch. ScopeMutex CallTheBall(Busy); // We're busy - don't touch.
if(isJob()) { // Only do a job if we have one. if(isJob()) { // Only do a job if we have one.
myJob().doIt(); myJob().doIt();
clearJob();
return true; return true;
} }
return false; return false;

+ 1
- 0
SNF4CGP/WorkerPool.hpp View File

Job* myJob_; // The job to do (or 0 to stop). Job* myJob_; // The job to do (or 0 to stop).
bool isJob(); // Job pointer check. bool isJob(); // Job pointer check.
Job& myJob(); // Safe access to myJob. Job& myJob(); // Safe access to myJob.
void clearJob(); // Forget done jobs.
public: public:
Worker(WorkerPool& W); // Initialize and start the thread. Worker(WorkerPool& W); // Initialize and start the thread.

Loading…
Cancel
Save