Use epoll in Ace

Source: Internet
Author: User
Use epoll2007-01-18 at in Ace
Thursday, June 8 th, 2006 

Obviously, the title of the article determines that Ace is used in Linux. We know that ace uses select to implement Reactor by default in Linux. The advantages of epoll over select are no longer mentioned here. Let's talk about the operation steps directly:
First, recompile the ace library.
The ACE Library supports epoll through the ace_dev_poll_reactor class, but the default installation of the ACE library does not compile this class. What we need to do is to connect ace_dev_poll_reactor compilation to the ace Library (faint, it takes more than an hour to recompile ace on my broken server ). my operating system is RedHat Linux as4.0, And the ace version is 5.4.10. Ace-install.html in the acecompressed package, I use"Building ace with GNU Autoconf"The installation steps are as follows (very simple, not translated ):
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.
Now we can finally explain how to compile ace_dev_poll_reactor into the ace library. Modify ace_wrappers/ACE/config-linux.h between Step 1 and step 2, add a line: # define ace_has_event_poll, and then perform steps 2nd, 3, 3rd .. /After configure is executed, some files and directories are generated under the build directory. Open ace_wrappers/build/ACE/config. h, add a row: # define ace_has_event_poll. Then, execute steps 4th make and 5th make install. OK. After a long compilation, the ace library that supports epoll is finally completed.

Second, modify the application
The application modification is very simple. Two lines of code are used to initialize the application (must be added between the first time ace_reactor: instance () is used:

M_pdevpollreactor = new ace_dev_poll_reactor;
Ace_reactor: instance (New ace_reactor (m_pdevpollreactor ));

The subsequent call to ace_reactor: instance () is to use ace_dev_poll_reactor.

Third: recompile the application

Add-dace_has_event_poll To The makefile of the application and re-make the application. OK.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.