2 //=============================================================================
4 * @file Upgradable_RW_Test.h
6 * It is only used by Upgradable_RW_Test.cpp.
8 * @author Michael Kircher <mk1@cs.wustl.edu>
10 //=============================================================================
13 #ifndef ACE_TESTS_UPGRADABLE_RW_TEST_H
14 #define ACE_TESTS_UPGRADABLE_RW_TEST_H
16 #include "test_config.h"
17 #include "ace/Barrier.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/Thread.h"
25 #include "ace/Thread_Manager.h"
26 #include "ace/Get_Opt.h"
27 #include "ace/SString.h"
28 #include "ace/Profile_Timer.h"
35 * @brief The members for the double linked list.
39 friend class ACE_Double_Linked_List
<Element
>;
40 friend class ACE_Double_Linked_List_Iterator_Base
<Element
>;
41 friend class ACE_Double_Linked_List_Iterator
<Element
>;
42 friend class ACE_Double_Linked_List_Reverse_Iterator
<Element
>;
45 Element (ACE_CString
*item
= 0,
65 typedef ACE_Double_Linked_List
<Element
> Linked_List
;
68 * @class Time_Calculation
70 * @brief class to do time calculations thread safe
72 class Time_Calculation
80 times_
.system_time
= 0;
83 /// take the time of the thread and add it to
84 void report_time (ACE_Profile_Timer::ACE_Elapsed_Time
&elapsed_time
);
89 /// add the times incrementally
90 ACE_Profile_Timer::ACE_Elapsed_Time times_
;
93 ACE_SYNCH_MUTEX mutex_
;
95 /// count how many threads gave me the elapsed_time
96 unsigned int reported_times_
;
102 * @brief A Task for readers
104 class Reader_Task
: public ACE_Task_Base
107 Reader_Task (Time_Calculation
&time_Calculation
,
108 ACE_Barrier
&barrier
)
109 : time_Calculation_ (time_Calculation
),
117 /// keep a reference to the time calculation class
118 Time_Calculation
&time_Calculation_
;
120 /// keep this reference for the barrier, in order
121 /// to allow a "nice" start
122 ACE_Barrier
&barrier_
;
128 * @brief A Task for wirters.
130 class Writer_Task
: public ACE_Task_Base
133 Writer_Task (Time_Calculation
&time_Calculation
,
134 ACE_Barrier
&barrier
)
135 : time_Calculation_ (time_Calculation
),
143 /// keep a reference to the time calculation class
144 Time_Calculation
&time_Calculation_
;
146 /// keep this reference for the barrier, in order
147 /// to allow a "nice" start
148 ACE_Barrier
&barrier_
;
151 #endif /* ACE_TESTS_UPGRADABLE_RW_TEST_H */