summaryrefslogtreecommitdiff
path: root/TAO/tao/Wait_Strategy.h
blob: f0a5179ab8923d9bc52485173dd2ae67661732d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// $Id$

// ============================================================================
//
// = LIBRARY
//     TAO
//
// = FILENAME
//     Wait_Strategy.h
//
// = DESCRIPTION
//     Classes to strategize waiting for reply.
//
// = AUTHOR
//     Alexander Babu Arulanthu <alex@cs.wustl.edu>
//
// ============================================================================


#include "tao/GIOP.h"

class TAO_Request_Mux_Strategy;
class TAO_Transport;
class TAO_IIOP_Handler_Base;

class TAO_Export TAO_Wait_Strategy
{
  // = TITLE
  //
  //    Strategy for waiting for the reply.
  // 
  // = DESCRIPTION
  // 
  
public:
  TAO_Wait_Strategy (TAO_Transport *transport);
  // Constructor.
  
  virtual ~TAO_Wait_Strategy (void);
  // Destructor.
  
  virtual int wait (void) = 0;
  // Base class virtual method.

  virtual int handle_input (void) = 0;
  // Handle the input.

  virtual int register_handler (TAO_IIOP_Handler_Base *handler) = 0;
  // Register the handler with the Reactor if it makes sense for the
  // strategy.

  virtual int resume_handler (ACE_Reactor *reactor) = 0;
  // Depending on the wait strategy resume the connect handler. 
  
protected:
  TAO_Transport *transport_;
  // Transport object.
};

class TAO_Export TAO_Wait_On_Reactor : public TAO_Wait_Strategy
{
  // = TITLE
  // 
  //    Wait on the Reactor. Happens in s Single Threaded client
  //    environment. 
  //
  // = DESCRIPTION
  //

public:
  TAO_Wait_On_Reactor (TAO_Transport *transport);
  // Constructor.
  
  virtual ~TAO_Wait_On_Reactor (void);
  // Destructor.
  
  virtual int wait (void);
  // Do the event loop of the Reactor.

  virtual int handle_input (void);
  // Handle the input. Delegate this job to Transport object. Before
  // that suspend the handler in the Reactor.

  virtual int register_handler (TAO_IIOP_Handler_Base *handler);
  // Register the handler with the Reactor.
  
  virtual int resume_handler (ACE_Reactor *reactor);
  // Resume the connection handler. 
};

class TAO_Export TAO_Wait_On_Leader_Follower : public TAO_Wait_Strategy
{
  // = TITLE
  //
  //    Wait according to the Leader-Follower model. Leader does the
  //    event loop of the Reactor and the Followers wait on the
  //    condition variable.
  //    
  // = DESCRIPTION
  // 

public:
  TAO_Wait_On_Leader_Follower (TAO_Transport *transport);
  // Constructor.
  
  virtual ~TAO_Wait_On_Leader_Follower (void);
  // Destructor.
  
  virtual int wait (void);
  // Wait according to the L-F model.

  virtual int handle_input (void);
  // Handle the input. Delegate this job to Transport object. Before
  // that, suspend the handler in the Reactor.

  virtual int register_handler (TAO_IIOP_Handler_Base *handler);
  // Register the handler with the Reactor.

  virtual int resume_handler (ACE_Reactor *reactor);
  // Resume the connection handler. 

  virtual int send_request (TAO_ORB_Core* orb_core,
                            TAO_OutputCDR &stream);
  // Send the request in <stream>.

protected:
  ACE_SYNCH_CONDITION* cond_response_available (void);
  // Return the cond_response_available, initializing it if necessary.
  
  ACE_thread_t calling_thread_;
  // the thread ID of the thread we were running in.
  
  ACE_SYNCH_CONDITION* cond_response_available_;
  // wait on reponse if the leader-follower model is active.
  
  int expecting_response_;
  // State flag which, if non-zero, indicates that we were expecting
  // respose. Otherwise, any input received is unexpected.
  // @@ Do we need this anymore? (Alex).

  int input_available_;
  // Flag indicating whether or not input is available.  Only valid
  // when <expecting_response_> is non-zero.
};

class TAO_Export TAO_Wait_On_Read :  public TAO_Wait_Strategy
{
  // = TITLE
  // 
  //    Wait on receiving the reply.
  //
  // = DESCRIPTION
  //
  
public:
  TAO_Wait_On_Read (TAO_Transport *transport);
  // Constructor.

  virtual ~TAO_Wait_On_Read (void);
  // Destructor.

  virtual int wait (void);
  // Wait on the read operation.

  virtual int handle_input (void);
  // Handle the input. Delegate this job to Transport object.

  virtual int register_handler (TAO_IIOP_Handler_Base *handler);
  // No-op. Return 0.
  
  virtual int resume_handler (ACE_Reactor *reactor);
  // Resume the connection handler. No-op. Returns 0.
};