#include <Select_Reactor_T.h>
Inheritance diagram for ACE_Select_Reactor_Token_T:


Public Methods | |
| ACE_Select_Reactor_Token_T (ACE_Select_Reactor_Impl &r, int s_queue=ACE_SELECT_TOKEN::FIFO) | |
| ACE_Select_Reactor_Token_T (int s_queue=ACE_SELECT_TOKEN::FIFO) | |
| virtual | ~ACE_Select_Reactor_Token_T (void) |
| virtual void | sleep_hook (void) |
| Called just before the ACE_Event_Handler goes to sleep. More... | |
| ACE_Select_Reactor_Impl & | select_reactor (void) |
| Get the select_reactor implementation. More... | |
| void | select_reactor (ACE_Select_Reactor_Impl &) |
| Set the select_reactor implementation. More... | |
| virtual void | dump (void) const |
| Dump the state of an object. More... | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. More... | |
Private Attributes | |
| ACE_Select_Reactor_Impl * | select_reactor_ |
This class is used to make the <ACE_Select_Reactor> thread-safe. By default, the thread that runs the <handle_events> loop holds the token, even when it is blocked in the <select> call. Whenever another thread wants to access the <ACE_Reactor> via its <register_handler>, <remove_handler>, etc. methods) it must ask the token owner for temporary release of the token. To accomplish this, the owner of a token must define a <sleep_hook> through which it can be notified to temporarily release the token if the current situation permits this. The owner of the token is responsible for deciding which request for the token can be granted. By using the <ACE_Token::renew> API, the thread that releases the token temporarily can specify to get the token back right after the other thread has completed using the token. Thus, there is a dedicated thread that owns the token ``by default.'' This thread grants other threads access to the token by ensuring that whenever somebody else has finished using the token the ``default owner'' first holds the token again, i.e., the owner has the chance to schedule other threads. The thread that most likely needs the token most of the time is the thread running the dispatch loop. Typically the token gets released prior to entering the <select> call and gets ``re-acquired'' as soon as the <select> call returns, which results probably in many calls to <release>/<acquire> that are not really needed since no other thread would need the token in the meantime. That's why the dispatcher thread is chosen to be the owner of the token. In case the token would have been released while in <select> there would be a good chance that the <fd_set> could have been modified while the <select> returns from blocking and trying to re-acquire the lock. Through the token mechanism it is ensured that while another thread is holding the token, the dispatcher thread is blocked in the <renew> call and not in <select>. Thus, it is not critical to change the <fd_set>. The implementation of the <sleep_hook> mechanism provided by the <ACE_Select_Reactor_Token> enables the default owner to be the thread that executes the dispatch loop.
Definition at line 70 of file Select_Reactor_T.h.
|
||||||||||||||||
|
Definition at line 200 of file Select_Reactor_T.cpp. References ACE_TRACE.
00202 : select_reactor_ (&r) 00203 { 00204 ACE_TRACE ("ACE_Select_Reactor_Token_T::ACE_Select_Reactor_Token"); 00205 00206 this->queueing_strategy (s_queue); 00207 } |
|
||||||||||
|
Definition at line 210 of file Select_Reactor_T.cpp. References ACE_TRACE.
00211 : select_reactor_ (0) 00212 { 00213 ACE_TRACE ("ACE_Select_Reactor_Token_T::ACE_Select_Reactor_Token"); 00214 00215 this->queueing_strategy (s_queue); 00216 } |
|
||||||||||
|
Definition at line 219 of file Select_Reactor_T.cpp. References ACE_TRACE.
00220 {
00221 ACE_TRACE ("ACE_Select_Reactor_Token_T::~ACE_Select_Reactor_Token_T");
00222 }
|
|
||||||||||
|
Dump the state of an object.
Definition at line 189 of file Select_Reactor_T.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.
00190 {
00191 ACE_TRACE ("ACE_Select_Reactor_Token_T::dump");
00192
00193 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00194 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
00195 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00196 }
|
|
||||||||||
|
Set the select_reactor implementation.
Definition at line 232 of file Select_Reactor_T.cpp.
00233 {
00234 this->select_reactor_ = &select_reactor;
00235 }
|
|
||||||||||
|
Get the select_reactor implementation.
Definition at line 225 of file Select_Reactor_T.cpp. References select_reactor_.
00226 {
00227 return *this->select_reactor_;
00228 }
|
|
||||||||||
|
Called just before the ACE_Event_Handler goes to sleep.
Definition at line 240 of file Select_Reactor_T.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, ACE_Reactor_Impl::notify, and select_reactor_.
00241 {
00242 ACE_TRACE ("ACE_Select_Reactor_Token_T::sleep_hook");
00243 if (this->select_reactor_->notify () == -1)
00244 ACE_ERROR ((LM_ERROR,
00245 ACE_LIB_TEXT ("%p\n"),
00246 ACE_LIB_TEXT ("sleep_hook failed")));
00247 }
|
|
|||||
|
Declare the dynamic allocation hooks.
Definition at line 92 of file Select_Reactor_T.h. |
|
|||||
|
Definition at line 95 of file Select_Reactor_T.h. Referenced by select_reactor, and sleep_hook. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002