协能can协议
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

JobExecuterImpl.h 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * JobExecuterImpl.h
  3. *
  4. * Created on: 2016年11月18日
  5. * Author: nego
  6. */
  7. #ifndef SERVICE_IMPL_JOBEXECUTERIMPL_H_
  8. #define SERVICE_IMPL_JOBEXECUTERIMPL_H_
  9. #include <pthread.h>
  10. #include "MThreadedJobQImpl.h"
  11. class JobI;
  12. class MThreadedJobQImpl;
  13. class JobExecuterImpl {
  14. public:
  15. //This function stops the Executer. Your code should not call this method.?
  16. void stop();
  17. //This points to the CMThreadedJobQ to which this instace belongs.?
  18. MThreadedJobQImpl* m_pJobQ;
  19. //This contain the refarence to a instance of CJob or it's child class.
  20. //The executer remains idle if this is NULL. That is when no job to do.
  21. JobI* m_pJob2Do;
  22. //This is used as a Flag. Two defind constats are
  23. //defined for this variable, they are STOP_WORKING (Value is -1),
  24. //KEEP_WORKING (value is 0 ). If the m_flaag value is set to STOP_WORKING then
  25. //the thread associated with the instance exists, else that thread is keep working.
  26. int m_flag;
  27. //This pointer keep a reference to the thread that
  28. //is associated with the class.
  29. pthread_t pid;
  30. //This operation is responsible for executing a job. The CMThreadedJobQ
  31. //class will call this function to get a job done. User should not call
  32. //this method, this is only for the use of the implementation of the
  33. //multithreaded job queue.
  34. void execute(JobI* pJob);
  35. //This is the static thread function. This function is used while
  36. //creating the thread in the constructor.
  37. static void* ThreadFunction(void* pParam);
  38. //Constructor
  39. JobExecuterImpl(MThreadedJobQImpl *pJobQ);
  40. virtual ~JobExecuterImpl();
  41. private:
  42. static pthread_mutex_t xLock;
  43. };
  44. #endif /* SERVICE_IMPL_JOBEXECUTERIMPL_H_ */