MADARA  3.2.3
BaseThread.h
Go to the documentation of this file.
1 
2 
3 #ifndef _MADARA_THREADS_BASE_THREAD_H_
4 #define _MADARA_THREADS_BASE_THREAD_H_
5 
14 #include <string>
15 #include <vector>
16 #include <map>
17 #include <list>
20 #include "madara/utility/StdInt.h"
21 #include "madara/MadaraExport.h"
24 
25 namespace madara
26 {
27  namespace threads
28  {
32  class WorkerThread;
33  class Threader;
34 
38  class BaseThread
39  {
40  public:
44  virtual ~BaseThread ()
45  {
46 
47  }
48 
53  friend class WorkerThread;
54  friend class Threader;
55 
59  virtual void init (knowledge::KnowledgeBase &)
60  {
61  }
62 
67  virtual void run (void) = 0;
68 
76  virtual void cleanup (void)
77  {
78  }
79 
80  protected:
81 
86  virtual void init_control_vars (
87  knowledge::KnowledgeBase & control)
88  {
89  terminated.set_name (name + ".terminated", control);
90  paused.set_name (name + ".paused", control);
91  }
92 
97 
103 
108  };
109  }
110 }
111 
112 #endif // _MADARA_THREADS_BASE_THREAD_H_
madara::knowledge::containers::Integer paused
thread safe paused flag that may be set by the Threader
Definition: BaseThread.h:107
virtual void init(knowledge::KnowledgeBase &)
Initializes thread with a MADARA context.
Definition: BaseThread.h:59
void set_name(const std::string &var_name, KnowledgeBase &knowledge)
Sets the variable name that this refers to.
Definition: Integer.inl:58
virtual void run(void)=0
Executes the main thread logic.
virtual void init_control_vars(knowledge::KnowledgeBase &control)
Initializes the Java thread implementation&#39;s control plane variables.
Definition: BaseThread.h:86
madara::knowledge::containers::Integer terminated
thread safe terminated flag that may be set by the Threader base
Definition: BaseThread.h:102
virtual ~BaseThread()
Destructor.
Definition: BaseThread.h:44
virtual void cleanup(void)
Cleans up any thread residue (usually instances created in init).
Definition: BaseThread.h:76
Provides a quality-of-service-enabled threading library.
Definition: BaseThread.h:27
static struct madara::knowledge::tags::string_t string
Abstract base class for implementing threads.
Definition: BaseThread.h:38
A thread that executes BaseThread logic.
Definition: WorkerThread.h:33
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
This class stores an integer within a variable context.
Definition: Integer.h:31
Starts threads with first class support of MADARA contexts.
Definition: Threader.h:35
std::string name
The unique name of your thread.
Definition: BaseThread.h:96
Copyright (c) 2015 Carnegie Mellon University.