Explorar el Código

Added clearJob()

git-svn-id: https://svn.microneil.com/svn/SNF4CGP/trunk@20 59e8e3e7-56fa-483b-b4b4-fa6ab0af3dfc
master
madscientist hace 15 años
padre
commit
2111d2b112
Se han modificado 2 ficheros con 6 adiciones y 0 borrados
  1. 5
    0
      SNF4CGP/WorkerPool.cpp
  2. 1
    0
      SNF4CGP/WorkerPool.hpp

+ 5
- 0
SNF4CGP/WorkerPool.cpp Ver fichero

@@ -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;

+ 1
- 0
SNF4CGP/WorkerPool.hpp Ver fichero

@@ -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.

Cargando…
Cancelar
Guardar