flyonok

统计

留言簿(7)

ACE

book

boost

bsd

c study

c++

code download

codeblock

computer clound

Eclipse

embed system

erlang

ET++

gtk

ic card

java

KDE

libevent

linux

linux--MM

mysql

network education

one card

oracle

pcap relation

php

powerbuilder

python

QT

software config

software test

SQL server

UML

wireless

wxwidgets

陈宾

阅读排行榜

评论排行榜

ace support epoll


转载 在ACE中使用epoll[zhuan]收藏
 很显然,文章的标题决定了我们是在linux下使用ACE。我们知道ACE在linux下缺省是用select来实现Reactor的,epoll相对于select的好处这里就不再多说了,我们直接讲操作步骤:
    第一:重新编译ACE库
     ACE 库中通过ACE_Dev_Poll_Reactor类来支持epoll,但是ACE库缺省的安装是没有编译这个类的,我们要做的就是将 ACE_Dev_Poll_Reactor编译连接到ACE库中(faint,又要重新编译ACE,在我那台破服务器上编译一次需要一个多小时).我的操作系统是Redhat linux AS4.0,ACE的版本是5.4.10。根据ACE压缩包中的ACE-INSTALL.html,我是用”Building ACE with GNU Autoconf“这种方式来安装的,安装步骤如下(很简单,就不翻译了):
       1 cd to the top-level ACE_wrappers directory.

       2.Create a subdirectory to hold your build’s configuration and built ACE version,     and   then change to the new directory:

       mkdir build

       cd build

     

       3.Note that you do not run the create_ace_build.pl utility mentioned in the Cloning the Source Tree section. The configure script takes care of creating all files and links that are needed.

Configure ACE for your platform by issuing the following command: c

       ../configure [options]

     
      4.Build ACE by typing make.

      5. Install ACE by typing make install.
      好,现在终于可以讲如何将ACE_Dev_Poll_Reactor编译到ACE库中去了。在上述的第一步和第二步之间修改ACE_wrappers/ace /config-linux.h,增加一行:#define ACE_HAS_EVENT_POLL,然后执行第2、3步,第3步.. /configure执行完之后,build目录下会生成一些文件和目录,打开ACE_wrappers/build/ace/config.h,增加一行:#define ACE_HAS_EVENT_POLL。然后执行第4步make和第5步make install.OK,在漫长的编译以后,支持 epoll的ACE库总算完成了。
     第二:修改应用程序
        应用程序修改很简单,两行代码搞掂,在应用程序初始化时(必须是在第一次使用ACE_Reactor::instance()之间)加入:
       
        m_pDevPollReactor=new ACE_Dev_Poll_Reactor;
       ACE_Reactor::instance(new ACE_Reactor(m_pDevPollReactor));
      
       那么在后续的对ACE_Reactor::instance()的调用就是使用ACE_Dev_Poll_Reactor的实现了。
  
   第三:重新编译应用程序
  
        在应用程序的makefile中加入 -DACE_HAS_EVENT_POLL,重新make应用程序。OK,打完收工。

posted on 2010-08-14 17:52 flyonok 阅读(676) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理