|
楼主 |
发表于 2010-7-26 14:40:11
|
显示全部楼层
这里确实需要修改一下ACE的源代码。
给ACE_Asynch_Read_Stream增加两个接口。把原来的- int
- ACE_Asynch_Read_Stream:open (ACE_Handler &handler,
- ACE_HANDLE handle,
- const void *completion_key,
- ACE_Proactor *proactor)
- {
- // Get a proactor for/from the user.
- proactor = this->get_proactor (proactor, handler);
- // Now let us get the implementation initialized.
- if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0)
- return -1;
- // Call the <open> method of the base class.
- return ACE_Asynch_Operation:open (handler,
- handle,
- completion_key,
- proactor);
- }
- 拆分成两个新的函数
- int
- ACE_Asynch_Read_Stream::Create(ACE_Handler &handler,
- ACE_HANDLE handle,
- ACE_Proactor *proactor)
- {
- proactor = this->get_proactor (proactor, handler);
- // Now let us get the implementation initialized.
- if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0)
- return -1;
- return 0;
- }
- int
- ACE_Asynch_Read_Stream::Bind(ACE_Handler &handler,
- ACE_HANDLE handle,
- const void *completion_key,
- ACE_Proactor *proactor)
- {
- // Call the <open> method of the base class.
- return ACE_Asynch_Operation:open (handler,
- handle,
- completion_key,
- proactor);
- }
复制代码 修改了一下ACE的源码,ACE_Asynch_Read_Stream和ACE_Asynch_Write_Stream对象,修改后,在高并发下CPU使用率明显降低。不过不能要求每个使用者都要重新改写一下ACE的代码吧。。。
既然ACE的Proactor提供了make_handler()方法,就是说明鼓励你使用自己的handler池,但是,这里却留下了一个陷阱。正在下载5.8看看有没有变化,modern在不,有QQ没?呵呵,加我一个吧。
|
|