Thread of example plugin. More...
#include <plugins/examples/basics/thread.h>
Public Member Functions | |
ExampleThread (fawkes::BlockedTimingAspect::WakeupHook hook, const char *name, unsigned int modc) | |
Constructor. | |
virtual | ~ExampleThread () |
Destructor. | |
virtual void | init () |
virtual void | loop () |
Thread loop. | |
virtual void | finalize () |
Protected Member Functions | |
virtual void | run () |
Stub to see name in backtrace for easier debugging. |
Thread of example plugin.
Definition at line 30 of file thread.h.
ExampleThread::ExampleThread | ( | fawkes::BlockedTimingAspect::WakeupHook | hook, | |
const char * | name, | |||
unsigned int | modc | |||
) |
Constructor.
hook | hook to register this thread for | |
name | thread name | |
modc | modulo count, every modc iterations a message is printed to stdout |
Definition at line 40 of file thread.cpp.
ExampleThread::~ExampleThread | ( | ) | [virtual] |
Destructor.
We cannot do the following: logger->log_info("ExampleThread", "Destroying thread %s", name());
The reason: We do not know if this thread has been successfully initialized. It could be, that any other thread that is in the same thread list as this thread failed to initialize, before the current thread has been initialized. In this case the LoggingAspect has not been initialized and thus logger is undefined and this would cause a fatal segfault.
Definition at line 51 of file thread.cpp.
void ExampleThread::loop | ( | ) | [virtual] |
Thread loop.
If num iterations module modc is 0 print out messaege, otherwise do nothing.
Definition at line 89 of file thread.cpp.
References fawkes::Logger::log_info(), fawkes::LoggingAspect::logger, and fawkes::Thread::name().
virtual void ExampleThread::run | ( | ) | [inline, protected, virtual] |