Fawkes API  Fawkes Development Version
fawkes::ThreadFinalizer Class Referenceabstract

Thread finalizer interface. More...

#include <core/threading/thread_finalizer.h>

Inheritance diagram for fawkes::ThreadFinalizer:

Public Member Functions

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

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

◆ ~ThreadFinalizer()

fawkes::ThreadFinalizer::~ThreadFinalizer ( )
virtual

Virtual empty destructor.

Definition at line 96 of file thread_finalizer.cpp.

Member Function Documentation

◆ finalize()

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

Referenced by fawkes::ThreadList::finalize(), fawkes::ThreadManager::force_remove(), fawkes::ThreadList::init(), and fawkes::ThreadManager::set_inifin().

◆ prepare_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::AspectManager.

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


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