FawkesMainThread Class Reference
Fawkes main thread. More...
#include <mainapp/main_thread.h>

Public Member Functions | |
| FawkesMainThread (fawkes::ArgumentParser *argp) | |
| Constructor. | |
| virtual | ~FawkesMainThread () |
| Destructor. | |
| virtual void | once () |
| Execute an action exactly once. | |
| virtual void | loop () |
| Code to execute in the thread. | |
| virtual void | set_mainloop_thread (fawkes::Thread *mainloop_thread) |
| Set a new main loop. | |
| virtual void | add_logger (fawkes::Logger *logger) |
| Add a new logger. | |
| virtual void | remove_logger (fawkes::Logger *logger) |
| Remove a logger. | |
Protected Member Functions | |
| virtual void | run () |
| Stub to see name in backtrace for easier debugging. | |
Detailed Description
Fawkes main thread.This thread initializes all important stuff like the BlackBoard, handles plugins and wakes up threads at defined hooks.
Definition at line 53 of file main_thread.h.
Constructor & Destructor Documentation
| FawkesMainThread::FawkesMainThread | ( | fawkes::ArgumentParser * | argp | ) |
Constructor.
- Parameters:
-
argp argument parser
Definition at line 65 of file main_thread.cpp.
References fawkes::MultiLogger::add_logger(), fawkes::Exception::append(), fawkes::ArgumentParser::arg(), FawkesThreadManager::aspect_collector(), fawkes::SQLiteConfiguration::SQLiteValueIterator::get_as_string(), fawkes::Configuration::get_bool(), fawkes::SQLiteConfiguration::SQLiteValueIterator::get_modtype(), fawkes::SQLiteConfiguration::SQLiteValueIterator::get_oldvalue(), fawkes::Configuration::get_string(), fawkes::Configuration::get_uint(), fawkes::ArgumentParser::has_arg(), FawkesNetworkManager::hub(), fawkes::Thread::init(), fawkes::Configuration::load(), fawkes::MultiLogger::log_debug(), fawkes::MultiLogger::log_info(), fawkes::MultiLogger::log_warn(), fawkes::SQLiteConfiguration::modified_iterator(), fawkes::Thread::name(), fawkes::SQLiteConfiguration::SQLiteValueIterator::next(), FawkesNetworkManager::nnresolver(), fawkes::SQLiteConfiguration::SQLiteValueIterator::path(), FawkesNetworkManager::service_browser(), FawkesNetworkManager::service_publisher(), fawkes::AspectIniFin::set_blocked_timing_executor(), fawkes::Configuration::set_default_uint(), fawkes::AspectIniFin::set_fnet_hub(), FawkesThreadManager::set_inifin(), fawkes::AspectIniFin::set_logger_employer(), fawkes::MultiLogger::set_loglevel(), fawkes::AspectIniFin::set_mainloop_employer(), fawkes::AspectIniFin::set_network_members(), fawkes::AspectIniFin::set_plugin_manager(), fawkes::Thread::start(), and fawkes::LocalBlackBoard::start_nethandler().
| FawkesMainThread::~FawkesMainThread | ( | ) | [virtual] |
Member Function Documentation
| void FawkesMainThread::add_logger | ( | fawkes::Logger * | logger | ) | [virtual] |
Add a new logger.
An exception should be thrown if anything prevents this from succeeding.
- Parameters:
-
logger logger to add
Implements fawkes::LoggerEmployer.
Definition at line 345 of file main_thread.cpp.
References fawkes::MultiLogger::add_logger().
| void FawkesMainThread::loop | ( | ) | [virtual] |
Code to execute in the thread.
Implement this method to hold the code you want to be executed continously. If you do not implement this method, the default is that the thread will exit. This is useful if you choose to only implement once().
Reimplemented from fawkes::Thread.
Definition at line 359 of file main_thread.cpp.
References fawkes::Mutex::lock(), fawkes::MultiLogger::log_debug(), fawkes::MultiLogger::log_error(), fawkes::MultiLogger::log_warn(), fawkes::TimeWait::mark_start(), fawkes::Thread::name(), fawkes::Time::stamp_systime(), fawkes::Thread::test_cancel(), FawkesThreadManager::timed_threads_exist(), FawkesThreadManager::try_recover(), fawkes::Mutex::unlock(), fawkes::InterruptibleBarrier::wait(), FawkesThreadManager::wait_for_timed_threads(), fawkes::TimeWait::wait_systime(), fawkes::Thread::wakeup(), FawkesThreadManager::wakeup_and_wait(), and fawkes::Thread::yield().
| void FawkesMainThread::once | ( | ) | [virtual] |
Execute an action exactly once.
This code is executed once and only once right after the thread is started before loop() is called. This is useful if you want to implement an one-shot background job. Just implement once() and leave once() untouched. Start the thread and detach it and it will just do its job and then die automatically. If you use set_delete_on_exit(true) even the Thread instance will be automatically deleted.
Reimplemented from fawkes::Thread.
Definition at line 310 of file main_thread.cpp.
References fawkes::ArgumentParser::arg(), fawkes::ArgumentParser::has_arg(), fawkes::PluginManager::load(), and fawkes::MultiLogger::log_error().
| void FawkesMainThread::remove_logger | ( | fawkes::Logger * | logger | ) | [virtual] |
Remove a logger.
An exception should be thrown if anything prevents this from succeeding.
- Parameters:
-
logger logger to remove
Implements fawkes::LoggerEmployer.
Definition at line 352 of file main_thread.cpp.
References fawkes::MultiLogger::remove_logger().
| virtual void FawkesMainThread::run | ( | ) | [inline, protected, virtual] |
Stub to see name in backtrace for easier debugging.
- See also:
- Thread::run()
Reimplemented from fawkes::Thread.
Definition at line 71 of file main_thread.h.
| void FawkesMainThread::set_mainloop_thread | ( | fawkes::Thread * | mainloop_thread | ) | [virtual] |
Set a new main loop.
Set the main loop. An exception should be thrown if anything prevents this from happening successful.
- Parameters:
-
mainloop_thread new main loop thread. The caller of this method must ensure that the thread operates in wait-for-wakeup mode and executes the main loop as its loop() method (i.e. the thread must have a properly initialized MainLoopAspect).
Implements fawkes::MainLoopEmployer.
Definition at line 332 of file main_thread.cpp.
References fawkes::InterruptibleBarrier::interrupt(), FawkesThreadManager::interrupt_timed_thread_wait(), fawkes::Mutex::lock(), fawkes::Thread::loopinterrupt_antistarve_mutex, and fawkes::Mutex::unlock().
The documentation for this class was generated from the following files:
- src/mainapp/main_thread.h
- src/mainapp/main_thread.cpp

