~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to ace/CLASSIX/CLASSIX_Select_Reactor.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- C++ -*- */
2
 
// CLASSIX_Select_Reactor.h,v 1.4 2003/07/19 19:04:15 dhinton Exp
3
 
 
4
 
/*
5
 
// ============================================================================
6
 
//
7
 
// = LIBRARY
8
 
//     ACE
9
 
//
10
 
// = FILENAME
11
 
//     CLASSIX_Reactor.h
12
 
//
13
 
// = AUTHOR(S)
14
 
//     Nokia Telecommunications
15
 
//
16
 
// ============================================================================
17
 
*/
18
 
 
19
 
#ifndef ACE_CLASSIX_REACTOR_H
20
 
#include /**/ "ace/pre.h"
21
 
#define ACE_CLASSIX_REACTOR_H
22
 
 
23
 
/* ------------------------------------------------------------------------- */
24
 
#include "ace/Timer_Queue.h"
25
 
 
26
 
#if !defined (ACE_LACKS_PRAGMA_ONCE)
27
 
# pragma once
28
 
#endif /* ACE_LACKS_PRAGMA_ONCE */
29
 
 
30
 
#include "ace/Select_Reactor.h"
31
 
#include "ace/Message_Block.h"
32
 
#include "ace/CLASSIX/CLASSIX_SAP.h"
33
 
 
34
 
class ACE_CLASSIX_Select_Reactor;
35
 
 
36
 
class ACE_Export ACE_CLASSIX_Select_Reactor_Notify :
37
 
    public ACE_Reactor_Notify
38
 
{
39
 
  // = TITLE
40
 
  //     Unblock the <ACE_CLASSIX_Select_Reactor> from its event loop.
41
 
  //
42
 
  // = DESCRIPTION
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.
46
 
  //
47
 
public:
48
 
    // = Initialization and termination methods.
49
 
    ACE_CLASSIX_Select_Reactor_Notify(void);
50
 
    ~ACE_CLASSIX_Select_Reactor_Notify(void);
51
 
 
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
58
 
 
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
62
 
    // Select_Reactor.
63
 
 
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).
76
 
 
77
 
    virtual int handle_input (ACE_HANDLE handle);
78
 
    // Called back by the Select_Reactor when a thread wants to unblock us.
79
 
 
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
83
 
    // Always 1.
84
 
 
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.
88
 
    // Always 1
89
 
 
90
 
    void dump (void) const;
91
 
    // Dump the state of an object.
92
 
 
93
 
    ACE_ALLOC_HOOK_DECLARE;
94
 
    // Declare the dynamic allocation hooks.
95
 
 
96
 
private:
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.
109
 
};
110
 
 
111
 
class ACE_CLASSIX_Select_Reactor : public ACE_Select_Reactor
112
 
    // = TITLE
113
 
    //   Implementing a Reactor for monitoring incoming data
114
 
    //
115
 
    // = DESCRIPTION
116
 
    //     This class redefines the wait_for_events() method of
117
 
    //     <ACE_Select_Reactor> class.
118
 
    //
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
124
 
    //     thread.
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.
133
 
    //
134
 
    //  = NOTE
135
 
    //   Since chorus does not allow ipcReceive to monitor a subset of
136
 
    //   ENABLED ports.  One cannot have two ACE_CLASSIX_Select_Reactors
137
 
    //   in one actor.
138
 
    //
139
 
{
140
 
  public:
141
 
 
142
 
 
143
 
    // = CURRENT MESSAGE
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.
154
 
 
155
 
 protected:
156
 
  // = INITIALIZATION
157
 
  ACE_CLASSIX_Select_Reactor (ACE_Timer_Queue * = 0);
158
 
  // Initializes <ACE_CLASSIX_Select__Reactor> with the handler
159
 
  // repository of the default size.
160
 
 
161
 
  ACE_CLASSIX_Select_Reactor (size_t size,
162
 
                              int restart = 0,
163
 
                              ACE_Timer_Queue * = 0);
164
 
  // Initializes <ACE_CLASSIX_Select_Reactor> with the handler repository of
165
 
  // size <size>.
166
 
 
167
 
  // multiplexer
168
 
  virtual int wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &,
169
 
                                        ACE_Time_Value *);
170
 
  // Wait for events to occur.
171
 
 
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
175
 
  // read next.
176
 
 
177
 
 
178
 
  // ACE_Recursive_Thread_Mutex  lock_current_;
179
 
  // lock for data relating to the current message.
180
 
  // use token lock
181
 
 
182
 
  size_t                      current_msg_size_;
183
 
  // size of the message that has just been detected.
184
 
 
185
 
  ACE_HANDLE                  current_handle_;
186
 
  // handler id of the current address.
187
 
 
188
 
  friend class ACE_CLASSIX_Select_Reactor_Notify;
189
 
  friend class ACE_CLASSIX_OS;
190
 
 // for constructors
191
 
 
192
 
 private:
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.
197
 
 
198
 
  ACE_CLASSIX_Select_Reactor(ACE_CLASSIX_Select_Reactor const&);
199
 
  ACE_CLASSIX_Select_Reactor const& operator=(ACE_CLASSIX_Select_Reactor const&);
200
 
};
201
 
 
202
 
/* ------------------------------------------------------------------------- */
203
 
 
204
 
#if defined (__ACE_INLINE__)
205
 
#include "ace/CLASSIX/CLASSIX_Select_Reactor.i"
206
 
#endif /* __ACE_INLINE__ */
207
 
 
208
 
#include /**/ "ace/post.h"
209
 
#endif /* ACE_CLASSIX_REACTOR_H */