Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Big_Oneways / Session.h
blob7dad8676bc45af98209c16060eeffa4b6fc6b35c
1 // -*- C++ -*-
2 #ifndef BIG_ONEWAYS_SESSION_H
3 #define BIG_ONEWAYS_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 /// Destructor
29 virtual ~Session (void);
31 /// Run one of the experiment threads
32 int svc (void);
34 // = The skeleton methods
35 virtual void start (const Test::Session_List &other_sessions);
37 virtual void ping (void);
39 virtual void receive_payload (const Test::Payload &the_payload);
41 virtual void destroy (void);
43 private:
44 /// Helper function used to report any problems and destroy local
45 /// resources
46 void terminate (CORBA::Boolean success);
48 /// Return 1 if all the work in this session has been completed
49 int more_work (void) const;
51 /// Make sure that all threads have connections avaiable to the
52 /// other sessions.
53 void validate_connections (void);
55 private:
56 /// Synchronize the internal state
57 TAO_SYNCH_MUTEX mutex_;
59 /// Keep a reference to the Session_Control, this is used to report
60 /// when the test finishes.
61 Test::Session_Control_var control_;
63 /// Keep track of wether the test is running.
64 int running_;
66 /// The other session objects participating in the test
67 Test::Session_List other_sessions_;
69 /// Size of each message
70 CORBA::ULong payload_size_;
72 /// Number of threads
73 CORBA::ULong thread_count_;
75 /// Number of messages to send
76 CORBA::ULong message_count_;
78 /// The number of threads currently running, when this reaches 0 the
79 /// session destroys itself.
80 CORBA::ULong active_thread_count_;
82 /// Number of messages expected
83 CORBA::ULong expected_messages_;
85 /// Helper class to run svc() in a separate thread
86 Session_Task task_;
88 /// Barrier to start all threads simultaneously
89 #if defined(ACE_HAS_THREADS)
90 typedef ACE_Thread_Barrier Barrier;
91 #else
92 typedef ACE_Null_Barrier Barrier;
93 #endif /* ACE_HAS_THREADS */
94 Barrier barrier_;
97 #include /**/ "ace/post.h"
99 #endif /* BIG_ONEWAYS_SESSION_H */