Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / tests / Upgradable_RW_Test.h
blobd6de6cbc2547e82a63c44bb0e083c5c2d40514d6
2 //=============================================================================
3 /**
4 * @file Upgradable_RW_Test.h
6 * It is only used by Upgradable_RW_Test.cpp.
8 * @author Michael Kircher <mk1@cs.wustl.edu>
9 */
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)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Task.h"
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"
30 class Element;
32 /**
33 * @class Element
35 * @brief The members for the double linked list.
37 class Element
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>;
44 public:
45 Element (ACE_CString *item = 0,
46 Element *p = 0,
47 Element *n = 0)
48 : prev_ (p),
49 next_(n),
50 item_(item)
54 ACE_CString *value ()
56 return this->item_;
59 private:
60 Element *prev_;
61 Element *next_;
62 ACE_CString *item_;
65 typedef ACE_Double_Linked_List<Element> Linked_List;
67 /**
68 * @class Time_Calculation
70 * @brief class to do time calculations thread safe
72 class Time_Calculation
74 public:
75 Time_Calculation ()
76 : reported_times_ (0)
78 times_.real_time = 0;
79 times_.user_time = 0;
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);
86 void print_stats ();
88 private:
89 /// add the times incrementally
90 ACE_Profile_Timer::ACE_Elapsed_Time times_;
92 /// protect the time
93 ACE_SYNCH_MUTEX mutex_;
95 /// count how many threads gave me the elapsed_time
96 unsigned int reported_times_;
99 /**
100 * @class Reader_Task
102 * @brief A Task for readers
104 class Reader_Task : public ACE_Task_Base
106 public:
107 Reader_Task (Time_Calculation &time_Calculation,
108 ACE_Barrier &barrier)
109 : time_Calculation_ (time_Calculation),
110 barrier_(barrier)
114 virtual int svc ();
116 private:
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_;
126 * @class Writer_Task
128 * @brief A Task for wirters.
130 class Writer_Task : public ACE_Task_Base
132 public:
133 Writer_Task (Time_Calculation &time_Calculation,
134 ACE_Barrier &barrier)
135 : time_Calculation_ (time_Calculation),
136 barrier_(barrier)
140 virtual int svc ();
142 private:
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 */