在ACE_Select_Reactor_T的handle_events中,进去就会获取Token,调到ACE_Guard直至ACE_Token的share_acquire函数,会调用一个sleepHook,这个hook的代码是:
00058 // Used to wakeup the reactor.
00059
00060 template <class ACE_TOKEN_TYPE> void
00061 ACE_Reactor_Token_T<ACE_TOKEN_TYPE>::sleep_hook (void)
00062 {
00063 ACE_TRACE ("ACE_Reactor_Token_T::sleep_hook");
00064 if (this->reactor_->notify () == -1)
00065 ACE_ERROR ((LM_ERROR,
00066 ACE_LIB_TEXT ("%p\n"),
00067 ACE_LIB_TEXT ("sleep_hook failed")));
00068 }
00069
由于这个Nofity实际是在handle_events
的最初始的地方,之后才是实际的多路复用函数select,后才到分发处理的dispatch。但是TP_Reactor是没有的,造成这个区别是什么呢?对比如下代码
01385 template <class ACE_SELECT_REACTOR_TOKEN> int
01386 ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::handle_events
01387 (ACE_Time_Value *max_wait_time)
01388 {
01389 ACE_TRACE ("ACE_Select_Reactor_T::handle_events");
01390
01391 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
01392
01393 // Stash the current time -- the destructor of this object will
01394 // automatically compute how much time elapsed since this method was
01395 // called.
01396 ACE_Countdown_Time countdown (max_wait_time);
01397
01398 ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1);
。。。。。。。
以及
00143 ACE_TP_Reactor::handle_events (ACE_Time_Value *max_wait_time)
00144 {
00145 ACE_TRACE ("ACE_TP_Reactor::handle_events");
00146
00147 // Stash the current time -- the destructor of this object will
00148 // automatically compute how much time elapsed since this method was
00149 // called.
00150 ACE_Countdown_Time countdown (max_wait_time);
00151
00152 //
00153 // The order of these events is very subtle, modify with care.
00154 //
00155
00156 // Instantiate the token guard which will try grabbing the token for
00157 // this thread.
00158 ACE_TP_Token_Guard guard (this->token_);
00159