Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / Big_Twoways / Session.h
blob9288200e1b304c01448c9f19654f4a0c36f9207e
1 // -*- C++ -*-
2 #ifndef BIG_TWOWAYS_SESSION_H
3 #define BIG_TWOWAYS_SESSION_H
5 #include /**/ "ace/pre.h"
7 #include "TestS.h"
8 #include "Session_Task.h"
10 #if defined(ACE_HAS_THREADS)
11 # include "ace/Barrier.h"
12 #else
13 # include "ace/Null_Barrier.h"
14 #endif /* ACE_HAS_THREADS */
16 /// Implement the Test::Session interface
17 class Session
18 : public virtual POA_Test::Session
20 public:
21 /// Constructor
22 Session (Test::Session_Control_ptr control,
23 CORBA::ULong payload_size,
24 CORBA::ULong thread_count,
25 CORBA::ULong message_count,
26 CORBA::ULong peer_count);
28 /// Run one of the experiment threads
29 int svc ();
31 // = The skeleton methods
32 virtual void start (const Test::Session_List &other_sessions);
34 virtual Test::Payload* echo_payload (const Test::Payload &the_payload);
36 virtual void destroy ();
38 protected:
39 /// Protected destructor, call _remove_ref() to delete
40 virtual ~Session ();
42 private:
43 /// Helper function used to report any problems and destroy local
44 /// resources
45 void terminate (CORBA::Boolean success);
47 /// Return 1 if all the work in this session has been completed
48 int more_work () const;
50 /// Validate all the connections
51 void validate_connections ();
53 private:
54 /// Synchronize the internal state
55 TAO_SYNCH_MUTEX mutex_;
57 /// Keep a reference to the Session_Control, this is used to report
58 /// when the test finishes.
59 Test::Session_Control_var control_;
61 /// Keep track of wether the test is running.
62 int running_;
64 /// The other session objects participating in the test
65 Test::Session_List other_sessions_;
67 /// Size of each message
68 CORBA::ULong payload_size_;
70 /// Number of threads
71 CORBA::ULong thread_count_;
73 /// Number of messages to send
74 CORBA::ULong message_count_;
76 /// The number of threads currently running, when this reaches 0 the
77 /// session destroys itself.
78 CORBA::ULong active_thread_count_;
80 /// Number of messages expected
81 CORBA::ULong expected_messages_;
83 /// Helper class to run svc() in a separate thread
84 Session_Task task_;
86 /// Barrier to start all threads simultaenously
87 #if defined(ACE_HAS_THREADS)
88 typedef ACE_Thread_Barrier Barrier;
89 #else
90 typedef ACE_Null_Barrier Barrier;
91 #endif /* ACE_HAS_THREADS */
92 Barrier barrier_;
95 #include /**/ "ace/post.h"
97 #endif /* BIG_TWOWAYS_SESSION_H */