|
在看ACE的关于Proactor的例子时候,有个地方没搞明白。就是在异步连接建立类(ACE_Aysnch_Acceptor)回调open的里边,发起了一个读操作,成功后却delete this?read不等于不是成功读取吗?为什么还要delete this?代码如下(就是这行"if (this->reader_.read (*mb, mb->space ()) != 0)".
void HA_Proactive_Service::open (ACE_HANDLE h, ACE_Message_Block&)
{
this->handle (h);
if (this->reader_.open (*this) != 0 ||
this->writer_.open (*this) != 0 )
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
ACE_TEXT ("HA_Proactive_Service open")));
delete this;
return;
}
ACE_Message_Block *mb;
ACE_NEW_NORETURN (mb, ACE_Message_Block (1024));
if (this->reader_.read (*mb, mb->space ()) != 0)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
ACE_TEXT ("HA_Proactive_Service begin read")));
mb->release ();
delete this;
return;
}
// mb is now controlled by Proactor framework.
return;
[ 本帖最后由 front_windy 于 2009-7-10 13:54 编辑 ] |
|