2 //=============================================================================
4 * @file Upgradable_RW_Test.h
6 * This class gets its own header file to work around AIX C++
7 * compiler "features" related to template instantiation... It is
8 * only used by Upgradable_RW_Test.cpp.
10 * @author Michael Kircher <mk1@cs.wustl.edu>
12 //=============================================================================
15 #ifndef ACE_TESTS_UPGRADABLE_RW_TEST_H
16 #define ACE_TESTS_UPGRADABLE_RW_TEST_H
18 #include "test_config.h"
19 #include "ace/Barrier.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "ace/Thread.h"
27 #include "ace/Thread_Manager.h"
28 #include "ace/Get_Opt.h"
29 #include "ace/SString.h"
30 #include "ace/Profile_Timer.h"
37 * @brief The members for the double linked list.
41 friend class ACE_Double_Linked_List
<Element
>;
42 friend class ACE_Double_Linked_List_Iterator_Base
<Element
>;
43 friend class ACE_Double_Linked_List_Iterator
<Element
>;
44 friend class ACE_Double_Linked_List_Reverse_Iterator
<Element
>;
47 Element (ACE_CString
*item
= 0,
56 ACE_CString
*value (void)
67 typedef ACE_Double_Linked_List
<Element
> Linked_List
;
70 * @class Time_Calculation
72 * @brief class to do time calculations thread safe
74 class Time_Calculation
77 Time_Calculation (void)
82 times_
.system_time
= 0;
85 /// take the time of the thread and add it to
86 void report_time (ACE_Profile_Timer::ACE_Elapsed_Time
&elapsed_time
);
88 void print_stats (void);
91 /// add the times incrementally
92 ACE_Profile_Timer::ACE_Elapsed_Time times_
;
95 ACE_SYNCH_MUTEX mutex_
;
97 /// count how many threads gave me the elapsed_time
98 unsigned int reported_times_
;
104 * @brief A Task for readers
106 class Reader_Task
: public ACE_Task_Base
109 Reader_Task (Time_Calculation
&time_Calculation
,
110 ACE_Barrier
&barrier
)
111 : time_Calculation_ (time_Calculation
),
119 /// keep a reference to the time calculation class
120 Time_Calculation
&time_Calculation_
;
122 /// keep this reference for the barrier, in order
123 /// to allow a "nice" start
124 ACE_Barrier
&barrier_
;
130 * @brief A Task for wirters.
132 class Writer_Task
: public ACE_Task_Base
135 Writer_Task (Time_Calculation
&time_Calculation
,
136 ACE_Barrier
&barrier
)
137 : time_Calculation_ (time_Calculation
),
145 /// keep a reference to the time calculation class
146 Time_Calculation
&time_Calculation_
;
148 /// keep this reference for the barrier, in order
149 /// to allow a "nice" start
150 ACE_Barrier
&barrier_
;
153 #endif /* ACE_TESTS_UPGRADABLE_RW_TEST_H */