2
// CLASSIX_Select_Reactor.h,v 1.4 2003/07/19 19:04:15 dhinton Exp
5
// ============================================================================
14
// Nokia Telecommunications
16
// ============================================================================
19
#ifndef ACE_CLASSIX_REACTOR_H
20
#include /**/ "ace/pre.h"
21
#define ACE_CLASSIX_REACTOR_H
23
/* ------------------------------------------------------------------------- */
24
#include "ace/Timer_Queue.h"
26
#if !defined (ACE_LACKS_PRAGMA_ONCE)
28
#endif /* ACE_LACKS_PRAGMA_ONCE */
30
#include "ace/Select_Reactor.h"
31
#include "ace/Message_Block.h"
32
#include "ace/CLASSIX/CLASSIX_SAP.h"
34
class ACE_CLASSIX_Select_Reactor;
36
class ACE_Export ACE_CLASSIX_Select_Reactor_Notify :
37
public ACE_Reactor_Notify
40
// Unblock the <ACE_CLASSIX_Select_Reactor> from its event loop.
43
// This replaces <ACE_Select_Reactor_Notify> class.
44
// Instead of using pipe, this class uses an Chorus IPC port to
45
// trigger the unblock event.
48
// = Initialization and termination methods.
49
ACE_CLASSIX_Select_Reactor_Notify(void);
50
~ACE_CLASSIX_Select_Reactor_Notify(void);
52
virtual int open (ACE_Reactor_Impl *,
53
ACE_Timer_Queue * = 0,
54
int = 0 /* dusable_notify_pip */);
55
// Enables the notification port and register it with the reactor
56
virtual int close (void);
57
// Disables the notification port
59
int dispatch_notifications (int &number_of_active_handles,
60
const ACE_Handle_Set &rd_mask);
61
// Handles pending threads (if any) that are waiting to unblock the
64
ssize_t notify (ACE_Event_Handler * = 0,
65
ACE_Reactor_Mask = ACE_Event_Handler::EXCEPT_MASK,
66
ACE_Time_Value * = 0);
67
// Called by a thread when it wants to unblock the Select_Reactor.
68
// This wakeups the <ACE_Select_Reactor> if currently blocked in
69
// select()/poll(). Pass over both the <Event_Handler> *and* the
70
// <mask> to allow the caller to dictate which <Event_Handler>
71
// method the <Select_Reactor> will invoke. The <ACE_Time_Value>
72
// indicates how long to blocking trying to notify the
73
// <Select_Reactor>. If <timeout> == 0, the caller will block until
74
// action is possible, else will wait until the relative time
75
// specified in *<timeout> elapses).
77
virtual int handle_input (ACE_HANDLE handle);
78
// Called back by the Select_Reactor when a thread wants to unblock us.
80
virtual void max_notify_iterations (int);
81
// Set the maximum number of times that the
82
// <ACE_CLASSIX_Reactor_Notify::handle_input> method will iterate
85
virtual int max_notify_iterations (void);
86
// Get the maximum number of times that the
87
// <ACE_Select_Reactor_Notify::handle_input> method will iterate.
90
void dump (void) const;
91
// Dump the state of an object.
93
ACE_ALLOC_HOOK_DECLARE;
94
// Declare the dynamic allocation hooks.
97
ACE_CLASSIX_Select_Reactor *select_reactor_;
98
// Keep a back pointer to the <ACE_Select_Reactor>. If this value
99
// if NULL then the <ACE_Select_Reactor> has been initialized with
100
// <disable_notify_pipe>.
101
ACE_CLASSIX_Port_Core notification_port_; // CLASSIX' IPC port
102
ACE_CLASSIX_SAP notification_sap_;
103
// The HANDLE that the Select_Reactor is listening on and
104
// the HANDLE that threads wanting the attention of the
105
// Select_Reactor will write t are the same.
106
// It can be seen that the notification port is implicitly connected to the
107
// port from where the notification is written. In many cases, it will be
108
// the actor's default port.
111
class ACE_CLASSIX_Select_Reactor : public ACE_Select_Reactor
113
// Implementing a Reactor for monitoring incoming data
116
// This class redefines the wait_for_events() method of
117
// <ACE_Select_Reactor> class.
119
// The wait_for_events() method uses ipcReceive() to monitor
120
// all ENABLED ports for incoming messages. The ipcReceive() is
121
// set up such that it will find out the size of the message but will
122
// not read the message. The Chorus OS provides an ipcGetData()
123
// to read the message that has just been detected on the same
125
// Once a message is detected on a particular
126
// port, the reactor will invoke the port handler's
127
// handle_input() method on the same thread. It is important that
128
// handle_input() shall immediately retrieve(use ipcGetData())
129
// the message on the same
130
// thread and it shall not hold up this thread in the handle_input()
131
// routine for too long. This will allow the Reactor to respond to
132
// events more quickly.
135
// Since chorus does not allow ipcReceive to monitor a subset of
136
// ENABLED ports. One cannot have two ACE_CLASSIX_Select_Reactors
144
// The following message should be called in the handler's
145
// handle_input() routine.
146
// The handle_input() routine should not hold the reactor for too long.
147
virtual int current_info(ACE_HANDLE /* port */,
148
size_t& /* msg size */);
149
// Retruns the current messageage to the caleer if the supplied
150
// handle id is the same as the <current_handle_>
151
// Returns 0, if <msg size> constains the size of the message
152
// that the handler shall read.
153
// Returns -1, if the caller is not the expected handler.
157
ACE_CLASSIX_Select_Reactor (ACE_Timer_Queue * = 0);
158
// Initializes <ACE_CLASSIX_Select__Reactor> with the handler
159
// repository of the default size.
161
ACE_CLASSIX_Select_Reactor (size_t size,
163
ACE_Timer_Queue * = 0);
164
// Initializes <ACE_CLASSIX_Select_Reactor> with the handler repository of
168
virtual int wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &,
170
// Wait for events to occur.
172
virtual int set_current_info_(ACE_HANDLE /* handle */,
173
size_t /* size of data */);
174
// record the handler and the size of the message that the handler shall
178
// ACE_Recursive_Thread_Mutex lock_current_;
179
// lock for data relating to the current message.
182
size_t current_msg_size_;
183
// size of the message that has just been detected.
185
ACE_HANDLE current_handle_;
186
// handler id of the current address.
188
friend class ACE_CLASSIX_Select_Reactor_Notify;
189
friend class ACE_CLASSIX_OS;
193
int handle_error_(int /* port handle */);
194
// Takes corrective action when errors occur.
195
int check_handles_(int /* port handle */);
196
// Makes sure the handler is valid.
198
ACE_CLASSIX_Select_Reactor(ACE_CLASSIX_Select_Reactor const&);
199
ACE_CLASSIX_Select_Reactor const& operator=(ACE_CLASSIX_Select_Reactor const&);
202
/* ------------------------------------------------------------------------- */
204
#if defined (__ACE_INLINE__)
205
#include "ace/CLASSIX/CLASSIX_Select_Reactor.i"
206
#endif /* __ACE_INLINE__ */
208
#include /**/ "ace/post.h"
209
#endif /* ACE_CLASSIX_REACTOR_H */