Fawkes API
Fawkes Development Version
thread_finalizer.cpp
1
2
/***************************************************************************
3
* thread_finalizer.cpp - Thread finalizer interface
4
*
5
* Created: Fri Jan 12 13:29:29 2007
6
* Copyright 2006-2007 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version. A runtime exception applies to
14
* this software (see LICENSE.GPL_WRE file mentioned below for details).
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Library General Public License for more details.
20
*
21
* Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22
*/
23
24
#include <core/threading/thread_finalizer.h>
25
26
namespace
fawkes
{
27
28
/** @class CannotFinalizeThreadException core/threading/thread_finalizer.h
29
* Thread cannot be finalized.
30
* Thrown if a thread could not be finalized for whatever reason.
31
* @ingroup Exceptions
32
*/
33
34
/** Constructor.
35
* @param format message format (reason or symptom of failure)
36
*/
37
CannotFinalizeThreadException::CannotFinalizeThreadException
(
const
char
*format, ...) :
Exception
()
38
{
39
va_list va;
40
va_start(va, format);
41
append_va
(format, va);
42
va_end(va);
43
}
44
45
/** Constructor.
46
* @param e exception to copy messages from
47
*/
48
CannotFinalizeThreadException::CannotFinalizeThreadException
(
Exception
&e) :
Exception
(e)
49
{
50
}
51
52
/** @class ThreadFinalizer core/threading/thread_finalizer.h
53
* Thread finalizer interface.
54
* This interface is used by the ThreadManager. The finalize() method is called
55
* for each thread that is about to be removed. If there are any special needs
56
* that have to be finalized before the thread is stopped on the given real
57
* classes of the thread this is the way to do it.
58
*
59
* The finalizer may abort the stopping of a thread by throwing a
60
* CannotFinalizeThreadException. This can for example be used if you have two
61
* threads A and B. A depends on B in that B is needed for A to run properly.
62
* Now both threads are running and then B is called to stop. The finalize will
63
* call threads B finalize() method, which fails (because it knows about the
64
* dependency of A for example by some kind of register pattern). This tells the
65
* thread manager not to stop B, because this would break A.
66
*
67
* See Fawkes main application for
68
* an example.
69
* @author Tim Niemueller
70
*
71
* @fn bool ThreadFinalizer::prepare_finalize(Thread *thread) = 0
72
* Prepare finalization of a thread.
73
* If the finalizer needs to do anything to prepare a maybe following finalize()
74
* can do so here. This is also the only place where it proclaim that finalizing
75
* the given thread at the given time is unsafe.
76
* The finalizer shall NOT call Thread::prepare_finalize().
77
* @param thread thread to prepare finalization for
78
* @return true if nothing prevents finalization, false otherwise
79
* @see Thread::prepare_finalize()
80
*
81
*
82
* @fn void ThreadFinalizer::finalize(Thread *thread) = 0
83
* Finalize a thread.
84
* This method is called by the ThreadManager for each Thread that is to be
85
* stopped and removed from the list of running threads.
86
* The finalizer shall NOT call Thread::finalize().
87
* @param thread thread to finalize.
88
* @exception CannotFinalizeThread thrown if thread can for not b finalized
89
* @see Thread::finalize()
90
*/
91
92
/** Virtual empty destructor. */
93
ThreadFinalizer::~ThreadFinalizer
()
94
{
95
}
96
97
}
// end namespace fawkes
fawkes::Exception::append_va
void append_va(const char *format, va_list va)
Append messages to the message list.
Definition:
exception.cpp:353
fawkes
Fawkes library namespace.
fawkes::CannotFinalizeThreadException::CannotFinalizeThreadException
CannotFinalizeThreadException(const char *format,...)
Constructor.
Definition:
thread_finalizer.cpp:37
fawkes::ThreadFinalizer::~ThreadFinalizer
virtual ~ThreadFinalizer()
Virtual empty destructor.
Definition:
thread_finalizer.cpp:93
fawkes::Exception
Base class for exceptions in Fawkes.
Definition:
exception.h:36
src
libs
core
threading
thread_finalizer.cpp
Generated by
1.8.20