ACE_Message_Block小知识
½
1 copy() 不需要让写指针后移.
ACE_Message_Block* mb = new ACE_Message_Block(BUFSIZ);
mb->copy(buff); //buff先已经初始化
2 初始化mb后需要后移指针的情况
2.1
ACE_Message_Block* mb = new ACE_Message_Block(buff,len);
mb->wt_ptr(len); //len是buff的长度 len = strlen(buff) +1
// +1 表示后面的\0
2.2
ACE_Message_Block* mb = new ACE_Message_Block(BUFSIZ);
ACE_OS::sprintf(mb->wt_ptr(),buff);
mb->wt_ptr(len);
2.3
ACE_Message_Block* mb = new ACE_Message_Block(len,
ACE_Message_Block::MB_DATA,
mb2, //表示 mb->cont(mb2)
buff)
mb->wt_ptr(len);
3.让消息接成串cont()时,千万不要直接或接间的把它接成一个环
mb->cont(mb2);
mb2->cont(mb3); //ok
***mb3->cont(mb); //死定了
4.通知其它线程结束时,可以通过ACE_Message_Block::MB_STOP
ACE_Message_Block* lastMsg =ACE_Message_Block ,ACE_Message_Block::MB_STOP)
otherTask->putq(lastMsg);