Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
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, ...)
38
:
Exception
()
39
{
40
va_list va;
41
va_start(va, format);
42
append_va
(format, va);
43
va_end(va);
44
}
45
46
/** Constructor.
47
* @param e exception to copy messages from
48
*/
49
CannotFinalizeThreadException::CannotFinalizeThreadException
(
Exception
&e)
50
:
Exception
(e)
51
{
52
}
53
54
55
/** @class ThreadFinalizer core/threading/thread_finalizer.h
56
* Thread finalizer interface.
57
* This interface is used by the ThreadManager. The finalize() method is called
58
* for each thread that is about to be removed. If there are any special needs
59
* that have to be finalized before the thread is stopped on the given real
60
* classes of the thread this is the way to do it.
61
*
62
* The finalizer may abort the stopping of a thread by throwing a
63
* CannotFinalizeThreadException. This can for example be used if you have two
64
* threads A and B. A depends on B in that B is needed for A to run properly.
65
* Now both threads are running and then B is called to stop. The finalize will
66
* call threads B finalize() method, which fails (because it knows about the
67
* dependency of A for example by some kind of register pattern). This tells the
68
* thread manager not to stop B, because this would break A.
69
*
70
* See Fawkes main application for
71
* an example.
72
* @author Tim Niemueller
73
*
74
* @fn bool ThreadFinalizer::prepare_finalize(Thread *thread) = 0
75
* Prepare finalization of a thread.
76
* If the finalizer needs to do anything to prepare a maybe following finalize()
77
* can do so here. This is also the only place where it proclaim that finalizing
78
* the given thread at the given time is unsafe.
79
* The finalizer shall NOT call Thread::prepare_finalize().
80
* @param thread thread to prepare finalization for
81
* @return true if nothing prevents finalization, false otherwise
82
* @see Thread::prepare_finalize()
83
*
84
*
85
* @fn void ThreadFinalizer::finalize(Thread *thread) = 0
86
* Finalize a thread.
87
* This method is called by the ThreadManager for each Thread that is to be
88
* stopped and removed from the list of running threads.
89
* The finalizer shall NOT call Thread::finalize().
90
* @param thread thread to finalize.
91
* @exception CannotFinalizeThread thrown if thread can for not b finalized
92
* @see Thread::finalize()
93
*/
94
95
/** Virtual empty destructor. */
96
ThreadFinalizer::~ThreadFinalizer
()
97
{
98
}
99
100
101
}
// end namespace fawkes
src
libs
core
threading
thread_finalizer.cpp
Generated by
1.8.1.1