2 #ifndef BIG_TWOWAYS_SESSION_H
3 #define BIG_TWOWAYS_SESSION_H
5 #include /**/ "ace/pre.h"
8 #include "Session_Task.h"
10 #if defined(ACE_HAS_THREADS)
11 # include "ace/Barrier.h"
13 # include "ace/Null_Barrier.h"
14 #endif /* ACE_HAS_THREADS */
16 /// Implement the Test::Session interface
18 : public virtual POA_Test::Session
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
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 ();
39 /// Protected destructor, call _remove_ref() to delete
43 /// Helper function used to report any problems and destroy local
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 ();
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.
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_
;
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
86 /// Barrier to start all threads simultaenously
87 #if defined(ACE_HAS_THREADS)
88 typedef ACE_Thread_Barrier Barrier
;
90 typedef ACE_Null_Barrier Barrier
;
91 #endif /* ACE_HAS_THREADS */
95 #include /**/ "ace/post.h"
97 #endif /* BIG_TWOWAYS_SESSION_H */