1.vs2005调试
http://blog.csdn.net/u010797208/article/details/40452797
2.macbook ace编译
http://www.jianshu.com/p/adc5938905f0
小坑:
源代码clockid_t重命名
GNUmakefile去掉SSL-target
http://blog.csdn.net/hpulizhen/article/details/49518677
http://blog.renren.com/share/251664336/7792179642
3.ACE
先分析一下ACE_wrappers\examples\Reactor\Proactor\test_proactor2.cpp的代码,
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) ACE_WIN32_Proactor * pImpl = new ACE_WIN32_Proactor; #elif defined (ACE_HAS_AIO_CALLS) // ACE_POSIX_AIOCB_Proactor * pImpl = new ACE_POSIX_AIOCB_Proactor;
ACE_POSIX_SIG_Proactor * pImpl = new ACE_POSIX_SIG_Proactor;
#endif ACE_Proactor Proactor ( pImpl , ); ACE_Proactor::instance( & Proactor );
ACE_INLINE int
ACE_Proactor::run_event_loop (void)
{
ACE_TRACE ("ACE_Proactor::run_event_loop");
ACE_Proactor *p = ACE_Proactor::instance (); if (p == )
return -; return p->proactor_run_event_loop (ACE_Proactor::check_reconfiguration);
}
int
ACE_Proactor::proactor_run_event_loop (PROACTOR_EVENT_HOOK eh)
{
ACE_TRACE ("ACE_Proactor::proactor_run_event_loop");
int result = ; {
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -)); // Early check. It is ok to do this without lock, since we care just
// whether it is zero or non-zero.
if (this->end_event_loop_ != )
return ; // First time you are in. Increment the thread count.
this->event_loop_thread_count_ ++;
} // Run the event loop.
for (;;)
{
// Check the end loop flag. It is ok to do this without lock,
// since we care just whether it is zero or non-zero.
if (this->end_event_loop_ != )
break; // <end_event_loop> is not set. Ready to do <handle_events>.
result = this->handle_events (); if (eh != && (*eh) (this))
continue; if (result == -)
break;
} // Leaving the event loop. Decrement the thread count. {
// Obtain the lock in the MT environments.
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -)); // Decrement the thread count.
this->event_loop_thread_count_ --; if (this->event_loop_thread_count_ >
&& this->end_event_loop_ != )
this->proactor_post_wakeup_completions ();
} return result;
}
int
ACE_Proactor::handle_events (void)
{
return this->implementation ()->handle_events ();
}
创建Proactor 时传入pImpl ,调用ACE_Proactor::run_event_loop () -> ACE_Proactor::proactor_run_event_loop(...) ->
ACE_Proactor::handle_events(), handle_events函数里还是调用pImp。
Proactor在windows上有实现,在其他平台也有实现,单独一个ACE_Proactor_Impl,然后继承实现是能理解的。将pImpl传入Proactor,Proactor很多方法实现就只是调用pImpl的相同函数而已,只是一种封装方式而已。
在其他项目中也有类似的封装,目的各有不同。
1.PlayContext和Play,应该只是把PlayContext的其他属性和方法隐藏
2.ACE_Refcounted_Auto_Ptr和ACE_Refcounted_Auto_Ptr_Rep, ACE_Refcounted_Auto_Ptr_Rep包含了引用计数,多个ACE_Refcounted_Auto_Ptr使用同一个ACE_Refcounted_Auto_Ptr_Rep
3.ACE_Proactor和ACE_Proactor_Impl,