Fawkes API
Fawkes Development Version
|
Thread finalizer interface. More...
#include <core/threading/thread_finalizer.h>
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... | |
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.
Definition at line 41 of file thread_finalizer.h.
|
virtual |
Virtual empty destructor.
Definition at line 96 of file thread_finalizer.cpp.
|
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().
thread | thread to finalize. |
CannotFinalizeThread | thrown if thread can for not b finalized |
Implemented in fawkes::AspectManager.
Referenced by fawkes::ThreadList::finalize(), fawkes::ThreadManager::force_remove(), fawkes::ThreadList::init(), and fawkes::ThreadManager::set_inifin().
|
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().
thread | thread to prepare finalization for |
Implemented in fawkes::AspectManager.
Referenced by fawkes::ThreadList::prepare_finalize().