MADARA  3.4.1
WorkerThread.inl
Go to the documentation of this file.
1 #ifndef _MADARA_THREADS_WORKER_THREAD_INL_
2 #define _MADARA_THREADS_WORKER_THREAD_INL_
3 
11 #include "WorkerThread.h"
12 
13 namespace madara
14 {
15 namespace threads
16 {
17 inline void WorkerThread::change_frequency(double hertz,
18  utility::TimeValue& current, utility::Duration& frequency,
19  utility::TimeValue& next_epoch, bool& one_shot, bool& blaster)
20 {
21  hertz_ = hertz;
22 #if 0
23  madara::logger::Logger::set_thread_hertz(hertz);
24 #endif
25  if (hertz_ > 0.0)
26  {
28  "WorkerThread(%s)::svc:"
29  " thread repeating at %f hz\n",
30  name_.c_str(), hertz_);
31 
32  one_shot = false;
33 
34  frequency = utility::seconds_to_duration(1.0 / hertz_);
35 
36  next_epoch = current;
37  next_epoch += frequency;
38  }
39  else if (hertz_ == 0.0)
40  {
41  // infinite hertz until terminate
42 
44  "WorkerThread(%s)::svc:"
45  " thread blasting at infinite hz\n",
46  name_.c_str());
47 
48  one_shot = false;
49  blaster = true;
50  }
51  else
52  {
54  "WorkerThread(%s)::svc:"
55  " thread running once\n",
56  name_.c_str());
57  }
58 }
59 }
60 }
61 
62 #endif // _MADARA_THREADS_WORKER_THREAD_H_
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
Definition: Logger.h:41
double hertz_
hertz rate for worker thread executions
Definition: WorkerThread.h:199
std::string name_
the name of the contained thread
Definition: WorkerThread.h:115
void change_frequency(double hertz, utility::TimeValue &current, utility::Duration &frequency, utility::TimeValue &next_epoch, bool &one_shot, bool &blaster)
Changes the frequency given a hertz rate.
T get(const KnowledgeRecord &kr)
Get the value of a KnowlegeRecord.
Definition: GetRecord.h:121
MADARA_EXPORT utility::Refcounter< logger::Logger > global_logger
Provides a quality-of-service-enabled threading library.
Definition: BaseThread.h:28
std::chrono::time_point< Clock > TimeValue
time point
Definition: Utility.h:36
std::chrono::nanoseconds Duration
default clock duration
Definition: Utility.h:30
Duration seconds_to_duration(double seconds)
Returns seconds in double format as nanosecond duration.
Definition: Utility.inl:277
Copyright(c) 2020 Galois.