1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// -*- C++ -*-
//=============================================================================
/**
* @file
*
* Header file for Loading DynamicTP Configurations.
*
* @author
*/
//=============================================================================
#ifndef TAO_DYNAMIC_TP_CONFIG_H
#define TAO_DYNAMIC_TP_CONFIG_H
#include /**/ "ace/pre.h"
#include "tao/orbconf.h"
#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
#include "tao/Dynamic_TP/dynamic_tp_export.h"
#include "ace/Service_Object.h"
#include "ace/Service_Config.h"
#include "ace/RB_Tree.h"
#include "ace/Synch.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
struct TAO_Dynamic_TP_Export TAO_DTP_Definition
{
int min_threads_; // a default of -1 implies Lifespan of INFINITE, > 0 implies IDLE
int init_threads_; // default to 5
int max_threads_; // a default of -1 implies no limit.
size_t stack_size_;
ACE_Time_Value timeout_; // default to 60 seconds
int queue_depth_;
// Create explicit constructor to eliminate issues with non-initialized struct values.
TAO_DTP_Definition() :
min_threads_(-1),
init_threads_(5),
max_threads_(-1),
stack_size_(ACE_DEFAULT_THREAD_STACKSIZE),
timeout_(60,0),
queue_depth_(0){}
};
class TAO_Dynamic_TP_Export TAO_DTP_Config_Registry_Installer
{
public:
TAO_DTP_Config_Registry_Installer (void);
};
class TAO_Dynamic_TP_Export TAO_DTP_Config_Registry : public ACE_Service_Object
{
public:
TAO_DTP_Config_Registry (void);
virtual ~TAO_DTP_Config_Registry (void);
virtual int init (int argc, ACE_TCHAR* []);
/// initializes the supplied set value with the configuration associated with the name, or returns false.
bool find (const ACE_CString& name, TAO_DTP_Definition &entry);
int bind (const ACE_CString& name, TAO_DTP_Definition &entry);
int rebind (const ACE_CString& name, TAO_DTP_Definition &entry);
private:
typedef ACE_RB_Tree<ACE_CString, TAO_DTP_Definition, ACE_Less_Than<ACE_CString>, ACE_Null_Mutex> Registry;
Registry registry_;
};
class TAO_Dynamic_TP_Export TAO_DTP_Config : public ACE_Service_Object
{
public:
/// Constructor.
TAO_DTP_Config (void);
/// Destructor.
virtual ~TAO_DTP_Config (void);
/// Read a definition parameter set from the supplied args.
/// There must be a -TPName argument, which, if replicated will cause the set to be ignored, unless -TPOverwrite is also set
/// constriants: min threads <= initial threads <= max_threads.
/// defaults: min threads = initial = max = 5
/// default lifespan = infinite
/// idle timeout is in secondes, default = 60
/// default stack size = 0, system defined default used.
/// queue depth is in number of messages, default is infinite
/// Init can be called multiple times,
virtual int init (int argc, ACE_TCHAR* []);
private:
int parse_long (int &curarg, int argc, ACE_TCHAR* argv[], const ACE_TCHAR *match, long &value);
int parse_bool (int &curarg, int argc, ACE_TCHAR* argv[], const ACE_TCHAR *match, bool &value);
int parse_string (int &curarg, int argc, ACE_TCHAR* argv[], const ACE_TCHAR *match, ACE_TCHAR *&value);
void report_option_value_error (const ACE_TCHAR* option_name,
const ACE_TCHAR* option_value);
};
static TAO_DTP_Config_Registry_Installer config_installer;
ACE_STATIC_SVC_DECLARE_EXPORT (TAO_Dynamic_TP, TAO_DTP_Config_Registry)
ACE_FACTORY_DECLARE (TAO_Dynamic_TP, TAO_DTP_Config_Registry)
ACE_STATIC_SVC_DECLARE_EXPORT (TAO_Dynamic_TP, TAO_DTP_Config)
ACE_FACTORY_DECLARE (TAO_Dynamic_TP, TAO_DTP_Config)
TAO_END_VERSIONED_NAMESPACE_DECL
#endif /* (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 */
#include /**/ "ace/post.h"
#endif /* TAO_DYNAMIC_TP_CONFIG_H */
|