| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /*
- * JobExecuterImpl.h
- *
- * Created on: 2016年11月18日
- * Author: nego
- */
-
- #ifndef SERVICE_IMPL_JOBEXECUTERIMPL_H_
- #define SERVICE_IMPL_JOBEXECUTERIMPL_H_
-
- #include <pthread.h>
- #include "MThreadedJobQImpl.h"
-
- class JobI;
- class MThreadedJobQImpl;
-
- class JobExecuterImpl {
- public:
- //This function stops the Executer. Your code should not call this method.?
- void stop();
-
- //This points to the CMThreadedJobQ to which this instace belongs.?
- MThreadedJobQImpl* m_pJobQ;
-
- //This contain the refarence to a instance of CJob or it's child class.
- //The executer remains idle if this is NULL. That is when no job to do.
- JobI* m_pJob2Do;
-
- //This is used as a Flag. Two defind constats are
- //defined for this variable, they are STOP_WORKING (Value is -1),
- //KEEP_WORKING (value is 0 ). If the m_flaag value is set to STOP_WORKING then
- //the thread associated with the instance exists, else that thread is keep working.
- int m_flag;
-
- //This pointer keep a reference to the thread that
- //is associated with the class.
- pthread_t pid;
-
- //This operation is responsible for executing a job. The CMThreadedJobQ
- //class will call this function to get a job done. User should not call
- //this method, this is only for the use of the implementation of the
- //multithreaded job queue.
- void execute(JobI* pJob);
-
- //This is the static thread function. This function is used while
- //creating the thread in the constructor.
- static void* ThreadFunction(void* pParam);
-
- //Constructor
- JobExecuterImpl(MThreadedJobQImpl *pJobQ);
-
- virtual ~JobExecuterImpl();
-
- private:
- static pthread_mutex_t xLock;
- };
-
- #endif /* SERVICE_IMPL_JOBEXECUTERIMPL_H_ */
|