Public Member Functions | Protected Member Functions

ExampleThread Class Reference

Thread of example plugin. More...

#include <plugins/examples/basics/thread.h>

Inheritance diagram for ExampleThread:
Inheritance graph
[legend]

List of all members.

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.

Detailed Description

Thread of example plugin.

Author:
Tim Niemueller

Definition at line 30 of file thread.h.


Constructor & Destructor Documentation

ExampleThread::ExampleThread ( fawkes::BlockedTimingAspect::WakeupHook  hook,
const char *  name,
unsigned int  modc 
)

Constructor.

Parameters:
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.


Member Function Documentation

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]

Stub to see name in backtrace for easier debugging.

See also:
Thread::run()

Definition at line 46 of file thread.h.


The documentation for this class was generated from the following files: