Fawkes API Fawkes Development Version

fawkes::ThreadFinalizer Class Reference

Thread finalizer interface. More...

#include <core/threading/thread_finalizer.h>

Inheritance diagram for fawkes::ThreadFinalizer:

List of all members.

Public Member Functions

virtual ~ThreadFinalizer ()
 Virtual empty destructor.
virtual bool prepare_finalize (Thread *thread)=0
 Prepare finalization of a thread.
virtual void finalize (Thread *thread)=0
 Finalize a thread.

Detailed Description

Thread finalizer interface.

This interface is used by the ThreadManager. The finalize() method is called for each thread that is about to be removed. If there are any special needs that have to be finalized before the thread is stopped on the given real classes of the thread this is the way to do it.

The finalizer may abort the stopping of a thread by throwing a CannotFinalizeThreadException. This can for example be used if you have two threads A and B. A depends on B in that B is needed for A to run properly. Now both threads are running and then B is called to stop. The finalize will call threads B finalize() method, which fails (because it knows about the dependency of A for example by some kind of register pattern). This tells the thread manager not to stop B, because this would break A.

See Fawkes main application for an example.

Author:
Tim Niemueller

Definition at line 41 of file thread_finalizer.h.


Constructor & Destructor Documentation

fawkes::ThreadFinalizer::~ThreadFinalizer ( ) [virtual]

Virtual empty destructor.

Definition at line 96 of file thread_finalizer.cpp.


Member Function Documentation

void fawkes::ThreadFinalizer::finalize ( Thread thread) [pure virtual]

Finalize a thread.

This method is called by the ThreadManager for each Thread that is to be stopped and removed from the list of running threads. The finalizer shall NOT call Thread::finalize().

Parameters:
threadthread to finalize.
Exceptions:
CannotFinalizeThreadthrown if thread can for not b finalized
See also:
Thread::finalize()

Implemented in fawkes::AspectIniFin.

Referenced by fawkes::ThreadList::finalize().

bool fawkes::ThreadFinalizer::prepare_finalize ( Thread thread) [pure virtual]

Prepare finalization of a thread.

If the finalizer needs to do anything to prepare a maybe following finalize() can do so here. This is also the only place where it proclaim that finalizing the given thread at the given time is unsafe. The finalizer shall NOT call Thread::prepare_finalize().

Parameters:
threadthread to prepare finalization for
Returns:
true if nothing prevents finalization, false otherwise
See also:
Thread::prepare_finalize()

Implemented in fawkes::AspectIniFin.

Referenced by fawkes::ThreadList::prepare_finalize().


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends