Chinaunix首页 | 论坛 | 博客
  • 博客访问: 819436
  • 博文数量: 756
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 4980
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 14:40
文章分类

全部博文(756)

文章存档

2011年(1)

2008年(755)

我的朋友

分类:

2008-10-13 16:11:59

#pragma once
#include
#include

class Fast_Asynch_Read_Stream : public ACE_Asynch_Read_Stream
{
public:
 Fast_Asynch_Read_Stream (void)
 {
 }

 /// Destructor.
 virtual ~Fast_Asynch_Read_Stream (void)
 {
 }

 int open (ACE_Handler &handler,
  ACE_HANDLE handle = ACE_INVALID_HANDLE,
  const void *completion_key = 0,
  ACE_Proactor *proactor = 0)
 {
  if(implementation_==NULL)
  {
   proactor = this->get_proactor (proactor, handler);
   if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0)
    return -1;
  }

  // Call the method of the base class.
  return ACE_Asynch_Operation::open (handler,
   handle,
   completion_key,
   proactor);
 }
};

class Fast_Asynch_Write_Stream : public ACE_Asynch_Write_Stream
{
public:

 Fast_Asynch_Write_Stream (void){}

 virtual ~Fast_Asynch_Write_Stream (void){}

 int open (ACE_Handler &handler,
  ACE_HANDLE handle = ACE_INVALID_HANDLE,
  const void *completion_key = 0,
  ACE_Proactor *proactor = 0)
 {
  if(implementation_==NULL)
  {
   proactor = this->get_proactor (proactor, handler);

   // Now let us get the implementation initialized.
   if ((this->implementation_ = proactor->create_asynch_write_stream ()) == 0)
    return -1;
  }
  // Call the method of the base class.
  return ACE_Asynch_Operation::open (handler,
   handle,
   completion_key,
   proactor);
 }
};


--------------------next---------------------
5.4的代码在这里,至少这里还检查了一下,能防止泄露。。。



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);

// Delete the old implementation.
delete this->implementation_;
this->implementation_ = 0;

// Now let us get the implementation initialized.
ACE_Asynch_Read_Stream_Impl *implementation = proactor->create_asynch_read_stream ();
if (implementation == 0)
return -1;

// Set the implementation class
this->implementation (implementation);

// Call the method of the base class.
return ACE_Asynch_Operation::open (handler,
handle,
completion_key,
proactor);
}

--------------------next---------------------

阅读(805) | 评论(0) | 转发(0) |
0

上一篇:简历模板一

下一篇:block封装的epoll

给主人留下些什么吧!~~