Fawkes API  Fawkes Development Version
timing_thread.h
1 /***************************************************************************
2  * timing_thread.h - Timing thread to achieve a desired main loop time
3  *
4  * Created: Thu Jul 23 14:45:42 2015
5  * Copyright 2015-2017 Till Hofmann
6  *
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef _LIBS_BASEAPP_TIMING_THREAD_H_
23 #define _LIBS_BASEAPP_TIMING_THREAD_H_
24 
25 #include <aspect/configurable.h>
26 #include <aspect/logging.h>
27 #include <aspect/syncpoint_manager.h>
28 #include <core/threading/thread.h>
29 #include <utils/time/clock.h>
30 
31 namespace fawkes {
32 
33 class FawkesTimingThread : public Thread,
35  public ConfigurableAspect,
36  // public ConfigurationChangeHandler,
37  public LoggingAspect
38 {
39 public:
41 
42  virtual void init();
43  virtual void loop();
44  virtual void finalize();
45 
46 private:
47  Clock *clock_;
48  Time * loop_start_;
49  Time * loop_end_;
50  float desired_loop_time_sec_;
51  uint desired_loop_time_usec_;
52  float min_loop_time_sec_;
53  uint min_loop_time_usec_;
54  bool enable_looptime_warnings_;
55 
56  RefPtr<SyncPoint> syncpoint_loop_start_;
57  RefPtr<SyncPoint> syncpoint_loop_end_;
58 };
59 
60 } // namespace fawkes
61 
62 #endif // LIBS_BASEAPP_TIMING_THREAD_H__
fawkes::FawkesTimingThread::finalize
virtual void finalize()
Finalize the thread.
Definition: timing_thread.cpp:130
fawkes::RefPtr< SyncPoint >
fawkes::FawkesTimingThread::loop
virtual void loop()
Thread loop.
Definition: timing_thread.cpp:87
fawkes::FawkesTimingThread
Thread to control the main loop timing.
Definition: timing_thread.h:38
fawkes
Fawkes library namespace.
fawkes::LoggingAspect
Thread aspect to log output.
Definition: logging.h:33
fawkes::FawkesTimingThread::init
virtual void init()
Initialize.
Definition: timing_thread.cpp:46
fawkes::Time
A class for handling time.
Definition: time.h:93
fawkes::Thread
Thread class encapsulation of pthreads.
Definition: thread.h:46
fawkes::ConfigurableAspect
Thread aspect to access configuration data.
Definition: configurable.h:33
fawkes::Clock
This is supposed to be the central clock in Fawkes.
Definition: clock.h:35
fawkes::SyncPointManagerAspect
Thread aspect to acces to SyncPoints Give this aspect to your thread to manage SyncPoints,...
Definition: syncpoint_manager.h:31