blob: 200e5d736196aaa41e630fc9503fdef7ef5e6cd5 (
plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
#define ACE_BUILD_SVC_DLL
#include "Baseline_Test.h"
# if defined (ACE_HAS_THREADS)
#include "ace/Log_Msg.h"
#include "ace/Token.h"
#include "ace/Process_Mutex.h"
#include "ace/RW_Mutex.h"
#include "ace/RW_Process_Mutex.h"
#include "ace/RW_Thread_Mutex.h"
#include "ace/Lock_Adapter_T.h"
#include "ace/Recursive_Thread_Mutex.h"
#include "ace/Semaphore.h"
#include "ace/Null_Semaphore.h"
#include "ace/Process_Semaphore.h"
template<class LOCK>
class ACE_Svc_Export Baseline_Lock_Test : public Baseline_Test_Base
{
public:
Baseline_Lock_Test ();
virtual ~Baseline_Lock_Test ();
virtual int acquire ();
virtual int release ();
// These two method are used to test try_acquire performance.
virtual int test_acquire_release ();
virtual int test_try_lock ();
// Real test methods.
private:
LOCK lock_;
//
};
template<class LOCK>
Baseline_Lock_Test<LOCK>::Baseline_Lock_Test ()
{
}
template<class LOCK>
Baseline_Lock_Test<LOCK>::~Baseline_Lock_Test ()
{
}
template<class LOCK> int
Baseline_Lock_Test<LOCK>::acquire ()
{
int retv = 0;
switch (this->what_)
{
case TEST_READLOCK:
retv = this->lock_.acquire_read ();
break;
case TEST_WRITELOCK:
retv = this->lock_.acquire_write ();
break;
case TEST_LOCK:
default:
retv = this->lock_.acquire ();
break;
}
return retv;
}
template<class LOCK> int
Baseline_Lock_Test<LOCK>::release ()
{
return this->lock_.release ();
}
template<class LOCK> int
Baseline_Lock_Test<LOCK>::test_acquire_release ()
{
baseline_options.start_inc_timer ();
switch (this->what_)
{
case TEST_READLOCK:
for (; baseline_options.inc_loop_counter () ; )
{
this->lock_.acquire_read ();
this->lock_.release ();
}
break;
case TEST_WRITELOCK:
for (; baseline_options.inc_loop_counter () ; )
{
this->lock_.acquire_write ();
this->lock_.release ();
}
break;
case TEST_LOCK:
default:
for (; baseline_options.inc_loop_counter () ; )
{
this->lock_.acquire ();
this->lock_.release ();
}
break;
}
baseline_options.stop_inc_timer ();
return 0;
}
template<class LOCK> int
Baseline_Lock_Test<LOCK>::test_try_lock ()
{
baseline_options.start_inc_timer ();
switch (this->what_)
{
case TEST_READLOCK:
for (; baseline_options.inc_loop_counter () ; )
this->lock_.tryacquire_read (); // This should always fail.
break;
case TEST_WRITELOCK:
for (; baseline_options.inc_loop_counter () ; )
this->lock_.tryacquire_write (); // This should always fail.
break;
case TEST_LOCK:
default:
for (; baseline_options.inc_loop_counter () ; )
this->lock_.tryacquire (); // This should always fail.
break;
}
for (; baseline_options.inc_loop_counter () ; )
this->lock_.tryacquire (); // This should always fail.
baseline_options.stop_inc_timer ();
return 0;
}
typedef Baseline_Lock_Test<ACE_Thread_Mutex> Baseline_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Mutex_Test)
typedef Baseline_Lock_Test<ACE_RW_Thread_Mutex> Baseline_RW_Thread_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_RW_Thread_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_RW_Thread_Mutex_Test)
typedef Baseline_Lock_Test<ACE_RW_Mutex> Baseline_RW_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_RW_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_RW_Mutex_Test)
typedef Baseline_Lock_Test<ACE_Process_Mutex> Baseline_Process_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Process_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Process_Mutex_Test)
typedef Baseline_Lock_Test<ACE_RW_Process_Mutex> Baseline_RW_Process_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_RW_Process_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_RW_Process_Mutex_Test)
typedef Baseline_Lock_Test<ACE_Null_Mutex> Baseline_Null_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Null_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Null_Mutex_Test)
typedef Baseline_Lock_Test< ACE_Lock_Adapter<ACE_Null_Mutex> > Baseline_Adaptive_Null_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Adaptive_Null_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Adaptive_Null_Mutex_Test)
typedef Baseline_Lock_Test<ACE_Recursive_Thread_Mutex> Baseline_Recursive_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Recursive_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Recursive_Mutex_Test)
typedef Baseline_Lock_Test< ACE_Lock_Adapter<ACE_Thread_Mutex> > Baseline_Adaptive_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Adaptive_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Adaptive_Mutex_Test)
typedef Baseline_Lock_Test< ACE_Lock_Adapter<ACE_RW_Mutex> > Baseline_Adaptive_RW_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Adaptive_RW_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Adaptive_RW_Mutex_Test)
typedef Baseline_Lock_Test< ACE_Lock_Adapter<ACE_Recursive_Thread_Mutex> > Baseline_Adaptive_Recursive_Mutex_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Adaptive_Recursive_Mutex_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Adaptive_Recursive_Mutex_Test)
typedef Baseline_Lock_Test<ACE_Semaphore> Baseline_Semaphore_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Semaphore_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Semaphore_Test)
typedef Baseline_Lock_Test<ACE_Semaphore> Baseline_Process_Semaphore_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Process_Semaphore_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Process_Semaphore_Test)
typedef Baseline_Lock_Test<ACE_Null_Semaphore> Baseline_Null_Semaphore_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Null_Semaphore_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Null_Semaphore_Test)
typedef Baseline_Lock_Test<ACE_Token> Baseline_Token_Test;
ACE_SVC_FACTORY_DECLARE (Baseline_Token_Test)
ACE_SVC_FACTORY_DEFINE (Baseline_Token_Test)
#endif /* ACE_HAS_THREADS */
|