MADARA  3.1.8
WorkerThread.h
Go to the documentation of this file.
1 #ifndef _MADARA_THREADS_WORKER_THREAD_H_
2 #define _MADARA_THREADS_WORKER_THREAD_H_
3 
12 #include <string>
13 #include <map>
14 
16 #include "BaseThread.h"
18 
19 #include "ace/Task.h"
20 
21 namespace madara
22 {
23  namespace threads
24  {
25  class Threader;
26 
31  class WorkerThread : public ACE_Task<ACE_NULL_SYNCH>
32  {
33  public:
35  friend class Threader;
36 
40  WorkerThread ();
41 
51  WorkerThread (
52  const std::string & name,
53  BaseThread * thread,
54  knowledge::KnowledgeBase * control,
56  double hertz = -1.0);
57 
61  WorkerThread (const WorkerThread & input) = delete;
62 
66  ~WorkerThread ();
67 
72  void operator= (const WorkerThread & input);
73 
77  int svc (void);
78 
82  void run (void);
83 
84  protected:
85 
96  void change_frequency (double hertz,
97  ACE_Time_Value & current, ACE_Time_Value & frequency,
98  ACE_Time_Value & next_epoch,
99  bool & one_shot, bool & blaster);
100 
103 
106 
109 
112 
118 
124 
129 
133  double hertz_;
134  };
135 
139  typedef std::map <std::string, WorkerThread *> NamedWorkerThreads;
140  }
141 }
142 
143 #include "WorkerThread.inl"
144 
145 #endif // _MADARA_THREADS_WORKER_THREAD_H_
This class stores a double within a variable context.
Definition: Double.h:32
WorkerThread()
Default constructor.
void operator=(const WorkerThread &input)
Assignment operator.
knowledge::KnowledgeBase * control_
the control plane to the knowledge base
Definition: WorkerThread.h:108
knowledge::KnowledgeBase * data_
the data plane (the knowledge base)
Definition: WorkerThread.h:111
knowledge::containers::Double new_hertz_
thread safe hertz reference
Definition: WorkerThread.h:128
double hertz_
hertz rate for worker thread executions
Definition: WorkerThread.h:133
void run(void)
Runs the thread once.
Provides a quality-of-service-enabled threading library.
Definition: BaseThread.h:27
void change_frequency(double hertz, ACE_Time_Value &current, ACE_Time_Value &frequency, ACE_Time_Value &next_epoch, bool &one_shot, bool &blaster)
Changes the frequency given a hertz rate.
Abstract base class for implementing threads.
Definition: BaseThread.h:38
A thread that executes BaseThread logic.
Definition: WorkerThread.h:31
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:44
This class stores an integer within a variable context.
Definition: Integer.h:31
std::string name_
the name of the contained thread
Definition: WorkerThread.h:102
static constexpr struct madara::knowledge::tags::string_t string
knowledge::containers::Integer started_
thread safe start flag that will be sent to the knowledge base on launch of the thread ...
Definition: WorkerThread.h:123
Starts threads with first class support of MADARA contexts.
Definition: Threader.h:35
knowledge::containers::Integer finished_
thread safe finished flag that will be sent to the knowledge base on completion of the thread ...
Definition: WorkerThread.h:117
std::map< std::string, WorkerThread * > NamedWorkerThreads
Collection of named threads.
Definition: WorkerThread.h:139
int svc(void)
Reads messages from a socket.
Copyright (c) 2015 Carnegie Mellon University.
BaseThread * thread_
the contained thread
Definition: WorkerThread.h:105