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_producer.cpp
1
2
/***************************************************************************
3
* thread_producer.cpp - Thread producer aspect for Fawkes
4
*
5
* Created: Tue Nov 20 11:26:24 2007
6
* Copyright 2006-2010 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 <aspect/thread_producer.h>
25
26
namespace
fawkes {
27
#if 0
/* just to make Emacs auto-indent happy */
28
}
29
#endif
30
31
/** @class ThreadProducerAspect <aspect/thread_producer.h>
32
* Aspect for thread producing threads.
33
* Some threads have to be started by a plugin after it is loaded. Thus
34
* they produce threads while they run. They may also stop this thread
35
* at any one time. To have all these threads registered with a central
36
* instance for easier instrumentation and performance assessment these
37
* threads should be registered with a central thread collector.
38
*
39
* Additionally the threads that are produced can have aspects that are
40
* then initialized by the thread collector (if running inside Fawkes).
41
* Note that initializing an aspect may fail and then an exception is
42
* thrown to indicate the error. You have to catch this exception and
43
* you may never start a thread in that case or unpredictable behavior
44
* will happen.
45
*
46
* This is possible with the ThreadProducerAspect. With this aspect you
47
* get access to a thread collector instance to register threads with.
48
*
49
* Remember to unregister the produced threads if they are cancelled,
50
* joined or even deleted!
51
*
52
* @ingroup Aspects
53
* @author Tim Niemueller
54
*/
55
56
57
/** @var ThreadCollector * ThreadProducerAspect::thread_collector
58
* Thread collector.
59
* Use this thread collector to register/unregister threads as they are
60
* created/deleted. It is set when the thread starts.
61
*/
62
63
/** Constructor. */
64
ThreadProducerAspect::ThreadProducerAspect()
65
{
66
add_aspect(
"ThreadProducerAspect"
);
67
}
68
69
/** Virtual empty destructor. */
70
ThreadProducerAspect::~ThreadProducerAspect()
71
{
72
}
73
74
75
/** Init thread producer aspect.
76
* This set the thread collector.
77
* It is guaranteed that this is called for a thread with the ThreadProducerAspect
78
* before start is called (when running regularly inside Fawkes).
79
* @param collector thread collector
80
*/
81
void
82
ThreadProducerAspect::init_ThreadProducerAspect(
ThreadCollector
*collector)
83
{
84
thread_collector = collector;
85
}
86
87
}
// end namespace fawkes
fawkes::ThreadCollector
Thread collector.
Definition:
thread_collector.h:34
src
libs
aspect
thread_producer.cpp
Generated by
1.8.7