PeriodicTask.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef COIL_PERIODICTASK_H
21 #define COIL_PERIODICTASK_H
22 
23 #include <map>
24 #include <string>
25 #include <vector>
26 #include <algorithm>
27 
28 #include <coil/Mutex.h>
29 #include <coil/Guard.h>
30 #include <coil/Condition.h>
31 #include <coil/TimeValue.h>
32 #include <coil/TimeMeasure.h>
33 #include <coil/PeriodicTaskBase.h>
34 
35 namespace coil
36 {
62  : public coil::PeriodicTaskBase
63  {
64  public:
66 
82  PeriodicTask();
83 
99  virtual ~PeriodicTask();
100 
123  virtual void activate();
124 
138  virtual void finalize();
139 
153  virtual int suspend(void);
154 
168  virtual int resume(void);
169 
183  virtual void signal();
184 
198  virtual bool setTask(TaskFuncBase* func, bool delete_in_dtor = true);
199 
217  template <class O, class F>
218  bool setTask(O* obj, F fun)
219  {
220  return this->setTask(new TaskFunc<O, F>(obj, fun));
221  }
222 
236  virtual void setPeriod(double period);
237 
251  virtual void setPeriod(TimeValue& period);
252 
260  virtual void executionMeasure(bool value);
261 
269  virtual void executionMeasureCount(int n);
270 
278  virtual void periodicMeasure(bool value);
279 
287  virtual void periodicMeasureCount(int n);
288 
297 
306 
307  protected:
315  virtual int svc();
316 
324  virtual void sleep();
325 
333  virtual void updateExecStat();
334 
342  virtual void updatePeriodStat();
343 
344  protected:
353 
361  bool m_nowait;
362 
371 
380 
390  class alive_t
391  {
392  public:
393  alive_t(bool val) : value(val) {}
394  bool value;
396  };
397 
406 
414  struct suspend_t
415  {
416  suspend_t(bool sus) : suspend(sus), mutex(), cond(mutex) {}
417  bool suspend;
420  };
421 
430 
439  {
442  };
443 
452 
460  unsigned int m_execCount;
461 
469  unsigned int m_execCountMax;
470 
479 
488 
497 
505  unsigned int m_periodCount;
506 
514  unsigned int m_periodCountMax;
515 
524 
533 
534  };
535 
536 }; // namespace coil
537 
538 #endif // COIL_PERIODICTASK_H
PeriodicTask()
Constructor.
bool m_deleteInDtor
Task execution function delete flag.
Definition: PeriodicTask.h:379
coil::TimeMeasure m_periodTime
Task periodic time measurement infomation.
Definition: PeriodicTask.h:532
unsigned int m_execCountMax
Task execution time measurement max count.
Definition: PeriodicTask.h:469
TaskFuncBase class.
Structure for time statistics.
Definition: TimeMeasure.h:63
virtual void periodicMeasure(bool value)
Validate a Task period time measurement.
virtual void updateExecStat()
Update for execute state.
Mutex class.
virtual void executionMeasure(bool value)
Validate a Task execute time measurement.
virtual int resume(void)
Resuming the suspended task.
coil::Condition< coil::Mutex > cond
Definition: PeriodicTask.h:419
virtual void activate()
Starting the task.
virtual int svc()
Thread execution for PeriodicTask.
unsigned int m_execCount
Task execution time measurement count.
Definition: PeriodicTask.h:460
virtual void periodicMeasureCount(int n)
Task period time measurement count.
coil::Guard< coil::Mutex > Guard
Definition: PeriodicTask.h:65
TaskFunc template class.
bool m_nowait
Thread sleep flag.
Definition: PeriodicTask.h:361
TimeValue class.
Definition: TimeValue.h:40
virtual void sleep()
Thread sleep.
virtual void signal()
Executing the suspended task one tick.
virtual TimeMeasure::Statistics getExecStat()
Get a result in task execute time measurement.
statistics_t m_execStat
Task execution time measurement statistics.
Definition: PeriodicTask.h:478
coil::TimeMeasure::Statistics stat
Definition: PeriodicTask.h:440
unsigned int m_periodCount
Task periodic time measurement count.
Definition: PeriodicTask.h:505
coil::TimeValue m_period
Task execution period.
Definition: PeriodicTask.h:352
bool setTask(O *obj, F fun)
Setting task execution function.
Definition: PeriodicTask.h:218
virtual bool setTask(TaskFuncBase *func, bool delete_in_dtor=true)
Setting task execution function.
unsigned int m_periodCountMax
Task periodic time measurement max count.
Definition: PeriodicTask.h:514
Structure for task suspend management.
Definition: PeriodicTask.h:414
statistics_t m_periodStat
Task periodic time measurement statistics.
Definition: PeriodicTask.h:523
PeriodicTaskBase class.
virtual ~PeriodicTask()
Destructor.
bool m_execMeasure
Task execution time measurement flag.
Definition: PeriodicTask.h:451
virtual void setPeriod(double period)
Setting task execution period.
virtual void executionMeasureCount(int n)
Task execute time measurement period.
coil::TimeMeasure m_execTime
Task execution time measurement infomation.
Definition: PeriodicTask.h:487
TaskFuncBase * m_func
Task execution function.
Definition: PeriodicTask.h:370
suspend_t m_suspend
Task suspend infomation.
Definition: PeriodicTask.h:429
TimeMeasure class.
Definition: TimeMeasure.h:49
virtual void updatePeriodStat()
Update for period state.
virtual void finalize()
Finalizing the task.
bool m_periodMeasure
Task periodic time measurement flag.
Definition: PeriodicTask.h:496
Structure for task execution time measurement management.
Definition: PeriodicTask.h:438
virtual TimeMeasure::Statistics getPeriodStat()
Get a result in task period time measurement.
alive_t m_alive
Task alive flag.
Definition: PeriodicTask.h:405
virtual int suspend(void)
Suspending the task.
Common Object Interface Layer.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:44