3 // $Id: Dev_Poll_Reactor.inl 80826 2008-03-04 14:51:23Z wotte $
5 #include "ace/Log_Msg.h"
7 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 ACE_Dev_Poll_Event_Tuple::ACE_Dev_Poll_Event_Tuple (void)
12 mask (ACE_Event_Handler::NULL_MASK),
17 // ---------------------------------------------------------------------
21 ACE_Dev_Poll_Ready_Set::ACE_Dev_Poll_Ready_Set (void)
28 // ---------------------------------------------------------------------
31 ACE_Dev_Poll_Reactor_Handler_Repository::mask (ACE_HANDLE handle,
32 ACE_Reactor_Mask mask)
34 ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask");
36 // Only bother to search for the handle if it's in range.
37 if (this->handle_in_range (handle))
38 this->handlers_[handle].mask = mask;
41 ACE_INLINE ACE_Reactor_Mask
42 ACE_Dev_Poll_Reactor_Handler_Repository::mask (ACE_HANDLE handle)
44 ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::mask");
46 ACE_Reactor_Mask mask = ACE_Event_Handler::NULL_MASK;
48 // Only bother to search for the handle if it's in range.
49 if (this->handle_in_range (handle))
50 mask = this->handlers_[handle].mask;
52 if (mask == ACE_Event_Handler::NULL_MASK)
59 ACE_Dev_Poll_Reactor_Handler_Repository::suspend (ACE_HANDLE handle)
61 ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspend");
63 // Only bother to search for the handle if it's in range.
64 if (this->handle_in_range (handle))
65 this->handlers_[handle].suspended = 1;
69 ACE_Dev_Poll_Reactor_Handler_Repository::resume (ACE_HANDLE handle)
71 ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::resume");
73 // Only bother to search for the handle if it's in range.
74 if (this->handle_in_range (handle))
75 this->handlers_[handle].suspended = 0;
79 ACE_Dev_Poll_Reactor_Handler_Repository::suspended (ACE_HANDLE handle) const
81 ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::suspended");
83 if (this->handle_in_range (handle))
84 return this->handlers_[handle].suspended;
90 ACE_Dev_Poll_Reactor_Handler_Repository::size (void) const
92 ACE_TRACE ("ACE_Dev_Poll_Reactor_Handler_Repository::size");
94 return this->max_size_;
97 // -----------------------------------------------------------------
100 ACE_Dev_Poll_Handler_Guard::ACE_Dev_Poll_Handler_Guard
101 (ACE_Event_Handler *eh,
110 eh->reference_counting_policy ().value () ==
111 ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
113 if (do_incr && this->refcounted_)
114 eh->add_reference ();
117 * The below comments were here when I replaced the old refcount
118 * scheme was replaced. They may still need addressing. -Steve Huston
122 * @todo Suspend the handler so that other threads will not cause
123 * an event that is already in an upcall from being dispatched
126 * @note The naive approach would be to simply call
127 * suspend_handler_i() on the reactor. However, that would
128 * cause a system call (write()) to occur. Obviously this
129 * can potentially have an adverse affect on performance.
130 * Ideally, the handler would only be marked as "suspended" in
131 * the handler repository. If an event arrives for a
132 * suspended handler that event can be "queued" in a
133 * "handle readiness queue." "Queued" is quoted since a real
134 * queue need not be used since duplicate events can be
135 * coalesced, thus avoiding unbounded queue growth. Event
136 * coalescing is already done by Linux's event poll driver
137 * (/dev/epoll) so Solaris' poll driver (/dev/poll) is the
138 * main concern here. The largest the queue can be is the
139 * same size as the number of handlers stored in the handler
145 ACE_Dev_Poll_Handler_Guard::~ACE_Dev_Poll_Handler_Guard (void)
147 if (this->refcounted_ && this->eh_ != 0)
148 this->eh_->remove_reference ();
151 * The below comments were here when I replaced the old refcount
152 * scheme was replaced. They may still need addressing. -Steve Huston
155 * @todo Resume the handler so that other threads will be allowed to
156 * dispatch the handler.
161 ACE_Dev_Poll_Handler_Guard::release (void)
166 // ---------------------------------------------------------------------
169 ACE_Dev_Poll_Reactor::upcall (ACE_Event_Handler *event_handler,
170 int (ACE_Event_Handler::*callback)(ACE_HANDLE),
173 // If the handler returns positive value (requesting a reactor
174 // callback) just call back as many times as the handler requests
175 // it. Other threads are off handling other things.
180 status = (event_handler->*callback) (handle);
188 /************************************************************************/
189 // Methods for ACE_Dev_Poll_Reactor::Token_Guard
190 /************************************************************************/
193 ACE_Dev_Poll_Reactor::Token_Guard::Token_Guard (ACE_Dev_Poll_Reactor_Token &token)
201 ACE_Dev_Poll_Reactor::Token_Guard::~Token_Guard (void)
203 if (this->owner_ == 1)
205 ACE_MT (this->token_.release ());
211 ACE_Dev_Poll_Reactor::Token_Guard::release_token (void)
215 ACE_MT (this->token_.release ());
217 // We are not the owner anymore..
223 ACE_Dev_Poll_Reactor::Token_Guard::is_owner (void)
228 ACE_END_VERSIONED_NAMESPACE_DECL