3 // $Id: Select_Reactor_T.inl 80826 2008-03-04 14:51:23Z wotte $
5 #include "ace/Reactor.h"
6 #include "ace/Signal.h"
7 #include "ace/Sig_Handler.h"
9 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
11 template <class ACE_SELECT_REACTOR_TOKEN>
13 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::resume_handler (ACE_Event_Handler *h)
15 ACE_TRACE ("ACE_Select_Reactor_T::resume_handler");
16 return this->resume_handler (h->get_handle ());
19 template <class ACE_SELECT_REACTOR_TOKEN>
21 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::resume_handler (const ACE_Handle_Set &handles)
23 ACE_TRACE ("ACE_Select_Reactor_T::resume_handler");
24 ACE_Handle_Set_Iterator handle_iter (handles);
27 ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
29 while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
30 if (this->resume_i (h) == -1)
36 template <class ACE_SELECT_REACTOR_TOKEN>
38 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::suspend_handler (ACE_Event_Handler *h)
40 ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler");
41 return this->suspend_handler (h->get_handle ());
44 template <class ACE_SELECT_REACTOR_TOKEN>
46 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::suspend_handler (const ACE_Handle_Set &handles)
48 ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler");
49 ACE_Handle_Set_Iterator handle_iter (handles);
52 ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
54 while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
55 if (this->suspend_i (h) == -1)
61 template <class ACE_SELECT_REACTOR_TOKEN>
63 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler (int signum,
64 ACE_Event_Handler *new_sh,
65 ACE_Sig_Action *new_disp,
66 ACE_Event_Handler **old_sh,
67 ACE_Sig_Action *old_disp)
69 ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
70 return this->signal_handler_->register_handler (signum,
75 #if defined (ACE_WIN32)
77 template <class ACE_SELECT_REACTOR_TOKEN>
79 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler (ACE_Event_Handler *,
82 // Don't have an implementation for this yet...
83 ACE_NOTSUP_RETURN (-1);
86 #endif /* ACE_WIN32 */
88 template <class ACE_SELECT_REACTOR_TOKEN>
90 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::register_handler (ACE_HANDLE ,
95 // Don't have an implementation for this yet...
96 ACE_NOTSUP_RETURN (-1);
99 template <class ACE_SELECT_REACTOR_TOKEN>
101 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handler (int signum, ACE_Event_Handler **handler)
103 ACE_TRACE ("ACE_Select_Reactor_T::handler");
104 return this->handler_i (signum, handler);
107 template <class ACE_SELECT_REACTOR_TOKEN>
109 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::remove_handler (int signum,
110 ACE_Sig_Action *new_disp,
111 ACE_Sig_Action *old_disp,
114 ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
115 return this->signal_handler_->remove_handler (signum, new_disp, old_disp, sigkey);
118 template <class ACE_SELECT_REACTOR_TOKEN>
120 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::uses_event_associations (void)
122 // Since the Select_Reactor does not do any event associations, this
123 // function always return 0.
127 // = The remaining methods in this file must be called with locks
130 // Performs operations on the "ready" bits.
132 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
133 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::ready_ops (ACE_Event_Handler *handler,
134 ACE_Reactor_Mask mask,
137 ACE_TRACE ("ACE_Select_Reactor_T::ready_ops");
138 return this->ready_ops (handler->get_handle (), mask, ops);
141 // Performs operations on the "dispatch" masks.
143 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
144 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::mask_ops (ACE_Event_Handler *handler,
145 ACE_Reactor_Mask mask,
148 ACE_TRACE ("ACE_Select_Reactor_T::mask_ops");
149 return this->mask_ops (handler->get_handle (), mask, ops);
152 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
153 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::schedule_wakeup (ACE_Event_Handler *eh,
154 ACE_Reactor_Mask mask)
156 ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup");
157 return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK);
160 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
161 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::cancel_wakeup (ACE_Event_Handler *eh,
162 ACE_Reactor_Mask mask)
164 ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup");
165 return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK);
168 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
169 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::schedule_wakeup (ACE_HANDLE handle,
170 ACE_Reactor_Mask mask)
172 ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup");
173 return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK);
176 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
177 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::cancel_wakeup (ACE_HANDLE handle,
178 ACE_Reactor_Mask mask)
180 ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup");
181 return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK);
184 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE ACE_Lock &
185 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::lock (void)
187 ACE_TRACE ("ACE_Select_Reactor_T::lock");
188 return this->lock_adapter_;
191 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE void
192 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::wakeup_all_threads (void)
194 // Send a notification, but don't block if there's no one to receive
196 this->notify (0, ACE_Event_Handler::NULL_MASK, (ACE_Time_Value *) &ACE_Time_Value::zero);
199 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
200 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::alertable_handle_events (ACE_Time_Value *max_wait_time)
202 return this->handle_events (max_wait_time);
205 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
206 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::alertable_handle_events (ACE_Time_Value &max_wait_time)
208 return this->handle_events (max_wait_time);
211 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE int
212 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::deactivated (void)
214 return this->deactivated_;
217 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE void
218 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::deactivate (int do_stop)
221 ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN,
224 this->deactivated_ = do_stop;
227 this->wakeup_all_threads ();
230 template <class ACE_SELECT_REACTOR_TOKEN> ACE_INLINE size_t
231 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::size (void) const
233 return this->handler_rep_.size ();
236 ACE_END_VERSIONED_NAMESPACE_DECL