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> 43 class ConfigNetworkHandler;
50 class PluginNetworkHandler;
51 class InterruptibleBarrier;
55 class SyncPointManager;
56 class 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_;
void full_start()
Start the thread and wait until once() completes.
Thread(const char *name)
Constructor.
virtual void log_error(const char *component, const char *format,...)
Log error message.
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Interface for signal handling.
Thread class encapsulation of pthreads.
virtual void run()
Stub to see name in backtrace for easier debugging.
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 loop()
Code to execute in the thread.
Log through multiple loggers.
virtual ~FawkesMainThread()
Destructor.
Base application thread manager.
WakeupHook
Type to define at which hook the thread is woken up.
This class gives access to SyncPoints.
Runner(FawkesMainThread *fmt, bool register_signals=true)
Constructor.
Main loop employer The MainLoopEmployer calls the main loop for execution.
virtual void wakeup_and_wait(BlockedTimingAspect::WakeupHook hook, unsigned int timeout_usec=0)
Wakeup thread for given hook and wait for completion.
void run()
Run main thread.
virtual void set_mainloop_thread(Thread *mainloop_thread)
Set a new main loop.
void handle_signal(int signum)
Handle signals.
MultiLogger * logger() const
Get logger.
Mutex mutual exclusion lock.
Fawkes default main thread.
Interface for configuration handling.
Utility class to run the main thread.
virtual void once()
Execute an action exactly once.