guodongxiaren opened a new pull request, #1888:
URL: https://github.com/apache/incubator-brpc/pull/1888

   event_dispatcher.cpp 同时兼容Linux和Mac系统,大量使用了条件编译的宏,这种条件编译的代码占了这个文件的大部分。
   
   导致这个代码文件可读性比较差,另外后续如果扩充其他操作系统、其他事件驱动的API,则event_dispatcher可维护性也比较差。
   参考Redis中事件驱动库Ae的源码组织形式:
   ```c
   #ifdef HAVE_EVPORT
   #include "ae_evport.c"
   #else
       #ifdef HAVE_EPOLL
       #include "ae_epoll.c"
       #else
           #ifdef HAVE_KQUEUE
           #include "ae_kqueue.c"
           #else
           #include "ae_select.c"
           #endif
       #endif
   #endif
   ```
   
   使用include 源文件的方式来隔离不同的操作系统的实现差异,单个文件可读性大大提升,也方便后续扩充其他系统的支持(只需要添加一个新的文件即可)
   
   新增的两个文件之所以后缀名之所以改成了cxx是因为当前的编译脚本会自动对cpp文件编译成 .o 
,但是新增的两个文件是无法单独编译的,它们其实是会被选择性地加入到event_dispatcher.cpp中一起编译。自己不能编译。所以改成了编译脚本当前不会自动独立编译的后缀cxx,并且cxx在某些习惯中也是常用的一种C++源文件后缀。
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to