2 #include "ace/Reactor.h"
3 #include "ace/Signal.h"
4 #include "ace/Sig_Handler.h"
6 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
8 template <class ACE_SELECT_REACTOR_TOKEN>
10 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::resume_handler (ACE_Event_Handler *h)
12 ACE_TRACE ("ACE_Select_Reactor_T::resume_handler");
13 return this->resume_handler (h->get_handle ());
16 template <class ACE_SELECT_REACTOR_TOKEN>
18 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::resume_handler (const ACE_Handle_Set &handles)
20 ACE_TRACE ("ACE_Select_Reactor_T::resume_handler");
21 ACE_Handle_Set_Iterator handle_iter (handles);
24 ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
26 while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
27 if (this->resume_i (h) == -1)
33 template <class ACE_SELECT_REACTOR_TOKEN>
35 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::suspend_handler (ACE_Event_Handler *h)
37 ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler");
38 return this->suspend_handler (h->get_handle ());
41 template <class ACE_SELECT_REACTOR_TOKEN>
43 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::suspend_handler (const ACE_Handle_Set &handles)
45 ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler");
46 ACE_Handle_Set_Iterator handle_iter (handles);
49 ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
51 while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
52 if (this->suspend_i (h) == -1)
58 template <class ACE_SELECT_REACTOR_TOKEN>
60 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler (int signum,
61 ACE_Event_Handler *new_sh,
62 ACE_Sig_Action *new_disp,
63 ACE_Event_Handler **old_sh,
64 ACE_Sig_Action *old_disp)
66 ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
67 return this->signal_handler_->register_handler (signum,
72 #if defined (ACE_WIN32)
73 template <class ACE_SELECT_REACTOR_TOKEN>
75 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler (ACE_Event_Handler *,
78 // Don't have an implementation for this yet...
79 ACE_NOTSUP_RETURN (-1);
81 #endif /* ACE_WIN32 */
83 template <class ACE_SELECT_REACTOR_TOKEN>
85 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler (ACE_HANDLE ,
90 // Don't have an implementation for this yet...
91 ACE_NOTSUP_RETURN (-1);
94 template <class ACE_SELECT_REACTOR_TOKEN>
96 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handler (int signum, ACE_Event_Handler **handler)
98 ACE_TRACE ("ACE_Select_Reactor_T::handler");
99 return this->handler_i (signum, handler);
102 template <class ACE_SELECT_REACTOR_TOKEN>
104 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::remove_handler (int signum,
105 ACE_Sig_Action *new_disp,
106 ACE_Sig_Action *old_disp,
109 ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
110 return this->signal_handler_->remove_handler (signum, new_disp, old_disp, sigkey);
113 template <class ACE_SELECT_REACTOR_TOKEN>
115 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::uses_event_associations ()
117 // Since the Select_Reactor does not do any event associations, this
118 // function always return false.
122 // = The remaining methods in this file must be called with locks
125 // Performs operations on the "ready" bits.
127 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
128 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::ready_ops (ACE_Event_Handler *handler,
129 ACE_Reactor_Mask mask,
132 ACE_TRACE ("ACE_Select_Reactor_T::ready_ops");
133 return this->ready_ops (handler->get_handle (), mask, ops);
136 // Performs operations on the "dispatch" masks.
138 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
139 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::mask_ops (ACE_Event_Handler *handler,
140 ACE_Reactor_Mask mask,
143 ACE_TRACE ("ACE_Select_Reactor_T::mask_ops");
144 return this->mask_ops (handler->get_handle (), mask, ops);
147 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
148 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::schedule_wakeup (ACE_Event_Handler *eh,
149 ACE_Reactor_Mask mask)
151 ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup");
152 return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK);
155 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
156 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::cancel_wakeup (ACE_Event_Handler *eh,
157 ACE_Reactor_Mask mask)
159 ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup");
160 return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK);
163 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
164 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::schedule_wakeup (ACE_HANDLE handle,
165 ACE_Reactor_Mask mask)
167 ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup");
168 return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK);
171 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
172 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::cancel_wakeup (ACE_HANDLE handle,
173 ACE_Reactor_Mask mask)
175 ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup");
176 return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK);
179 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE ACE_Lock &
180 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::lock ()
182 ACE_TRACE ("ACE_Select_Reactor_T::lock");
183 return this->lock_adapter_;
186 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE void
187 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::wakeup_all_threads ()
189 // Send a notification, but don't block if there's no one to receive
191 this->notify (0, ACE_Event_Handler::NULL_MASK, (ACE_Time_Value *) &ACE_Time_Value::zero);
194 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
195 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::alertable_handle_events (ACE_Time_Value *max_wait_time)
197 return this->handle_events (max_wait_time);
200 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
201 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::alertable_handle_events (ACE_Time_Value &max_wait_time)
203 return this->handle_events (max_wait_time);
206 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
207 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::deactivated ()
209 return this->deactivated_;
212 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE void
213 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::deactivate (int do_stop)
216 ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN,
219 this->deactivated_ = static_cast<sig_atomic_t> (do_stop);
222 this->wakeup_all_threads ();
225 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE size_t
226 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::size () const
228 return this->handler_rep_.size ();
231 ACE_END_VERSIONED_NAMESPACE_DECL