24#ifndef _LIBS_BASEAPP_MAIN_THREAD_H_
25#define _LIBS_BASEAPP_MAIN_THREAD_H_
27#include <aspect/blocked_timing.h>
28#include <aspect/mainloop/employer.h>
29#include <baseapp/thread_manager.h>
30#include <core/threading/thread.h>
31#include <logging/multi.h>
32#include <syncpoint/syncpoint_manager.h>
33#include <utils/system/signal.h>
43class ConfigNetworkHandler;
50class PluginNetworkHandler;
51class InterruptibleBarrier;
55class SyncPointManager;
56class FawkesNetworkManager;
66 const char * load_plugins,
67 const char * default_plugin = 0);
93 bool register_signals_;
112 }
catch (Exception &e) {
113 if (enable_looptime_warnings_) {
117 multi_logger_->
log_error(
"FawkesMainThread", e);
122 Configuration *config_;
123 MultiLogger * multi_logger_;
125 TimeWait * time_wait_;
127 Barrier * init_barrier_;
128 Thread * mainloop_thread_;
129 Mutex * mainloop_mutex_;
130 InterruptibleBarrier *mainloop_barrier_;
132 char *default_plugin_;
135 ThreadManager * thread_manager_;
136 SyncPointManager *syncpoint_manager_;
137 PluginManager * plugin_manager_;
139 std::list<std::string> recovered_threads_;
140 unsigned int desired_loop_time_usec_;
141 float desired_loop_time_sec_;
142 unsigned int max_thread_time_usec_;
143 unsigned int max_thread_time_nanosec_;
146 bool enable_looptime_warnings_;
148 std::vector<RefPtr<SyncPoint>> syncpoints_start_hook_;
149 std::vector<RefPtr<SyncPoint>> syncpoints_end_hook_;
WakeupHook
Type to define at which hook the thread is woken up.
Interface for configuration handling.
Utility class to run the main thread.
Runner(FawkesMainThread *fmt, bool register_signals=true)
Constructor.
void run()
Run main thread.
void handle_signal(int signum)
Handle signals.
Fawkes default main thread.
virtual void set_mainloop_thread(Thread *mainloop_thread)
Set a new main loop.
virtual void once()
Execute an action exactly once.
void full_start()
Start the thread and wait until once() completes.
MultiLogger * logger() const
Get logger.
FawkesMainThread(Configuration *config, MultiLogger *multi_logger, ThreadManager *thread_manager, SyncPointManager *syncpoint_manager, PluginManager *plugin_manager, const char *load_plugins, const char *default_plugin=0)
Constructor.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void loop()
Code to execute in the thread.
virtual ~FawkesMainThread()
Destructor.
Main loop employer The MainLoopEmployer calls the main loop for execution.
Log through multiple loggers.
virtual void log_error(const char *component, const char *format,...)
Log error message.
Mutex mutual exclusion lock.
Interface for signal handling.
This class gives access to SyncPoints.
Base application thread manager.
virtual void wakeup_and_wait(BlockedTimingAspect::WakeupHook hook, unsigned int timeout_usec=0)
Wakeup thread for given hook and wait for completion.
Thread class encapsulation of pthreads.
Thread(const char *name)
Constructor.
virtual void run()
Code to execute in the thread.
Fawkes library namespace.