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
31namespace fawkes {
32
35 public ConfigurableAspect,
36 // public ConfigurationChangeHandler,
37 public LoggingAspect
38{
39public:
41
42 virtual void init();
43 virtual void loop();
44 virtual void finalize();
45
46private:
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__
This is supposed to be the central clock in Fawkes.
Definition: clock.h:35
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread to control the main loop timing.
Definition: timing_thread.h:38
virtual void finalize()
Finalize the thread.
virtual void init()
Initialize.
virtual void loop()
Thread loop.
Thread aspect to log output.
Definition: logging.h:33
Thread aspect to acces to SyncPoints Give this aspect to your thread to manage SyncPoints,...
Thread class encapsulation of pthreads.
Definition: thread.h:46
A class for handling time.
Definition: time.h:93
Fawkes library namespace.