All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TaskWorker.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "ActiveObject.h"
6 #include "ITaskMessage.h"
7 #include "ITaskPoolMessage.h"
8 #include "ITaskMessageDispatcher.h"
9 #include "Tasks.h"
10 #include "TaskWorkerState.h"
11 
12 namespace Eegeo
13 {
14  namespace Concurrency
15  {
16  namespace Tasks
17  {
18  class TaskWorker : public Eegeo::Messaging::ActiveObject<Messages::ITaskMessage*, Messages::ITaskMessageDispatcher>
19  {
20  public:
23  virtual ~TaskWorker();
24  virtual void Start();
25  virtual void RequestStop() { };
26  virtual void Stop();
27  virtual void OnStop() { };
28 
29  void OnMessageHandled(Messages::ITaskMessage* message);
30 
31  bool IsRunning() const;
32  TaskWorkerState::Values GetState() const;
33 
34  bool HandleMessage(const Tasks::Messages::StopWorkerMessage& stopWorkerMessage);
35  bool HandleMessage(const Tasks::Messages::PerformWorkMessage& performWorkMessage);
36 
37  protected:
38  virtual void PerformWork(WorkItem& workItem);
39 
40  private:
42  TaskWorkerState::Values m_state;
43  };
44  }
45  }
46 }
47