本文整理汇总了C++中ACE_Message_Block::base方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Message_Block::base方法的具体用法?C++ ACE_Message_Block::base怎么用?C++ ACE_Message_Block::base使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Message_Block
的用法示例。
在下文中一共展示了ACE_Message_Block::base方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
Sender::on_data_sent(ACE_Message_Block & mb,
const ACE_INET_Addr & remote)
{
int nbytes = mb.length ();
if (nbytes == 0)
{
mb.release();
return 0;
}
if (this->io_count_r_ == 0)
this->initiate_read();
if (this->io_count_w_ == 0)
{
mb.rd_ptr(mb.base());
mb.wr_ptr(mb.base() + nbytes);
this->initiate_write(mb, remote);
}
return 0;
}
示例2:
int
JAWS_TPOOL_Concurrency::getq (JAWS_Protocol_Handler *&ph)
{
ph = 0;
JAWS_CONCURRENCY_TASK *task = this;
if (this->shutdown_task_ && task->msg_queue ()->message_count () == 0)
return -1;
ACE_Message_Block *mb = 0;
int result = task->getq (mb);
if (result != -1)
{
ph = (JAWS_Protocol_Handler *) mb->base ();
if (ph == 0)
{
// Shutdown this task;
this->shutdown_task_ = 1;
if (this->number_of_threads_ && this->number_of_threads_-- > 1)
{
task->putq (mb);
result = -1;
}
}
}
return result;
}
示例3: initiate_io
int
Sender::initiate_write (void)
{
if ( this->msg_queue ()->message_count () < 20) // flow control
{
size_t nbytes = ACE_OS::strlen (send_buf_);
ACE_Message_Block *mb = 0;
ACE_NEW_RETURN (mb,
ACE_Message_Block (nbytes+8),
-1);
mb->init (send_buf_, nbytes);
mb->rd_ptr (mb->base ());
mb->wr_ptr (mb->base ());
mb->wr_ptr (nbytes);
ACE_Time_Value tv = ACE_Time_Value::zero;
int qcount =this->putq (mb, & tv);
if (qcount <= 0)
{
ACE_Message_Block::release (mb);
return -1;
}
}
return initiate_io (ACE_Event_Handler::WRITE_MASK);
}
示例4: if
void
PConnection::trace_buffers(const Buffer_Info& buf_info,
size_t xfer_bytes,
bool flg_read)
{
int iovcnt = buf_info.get_iov_count ();
if (iovcnt < 0) // ACE_Message_Block
{
ACE_Message_Block * mb = buf_info.get_message_block_ptr();
for (int i=0;
xfer_bytes != 0 && mb != 0 ;
mb = mb->cont (), ++i)
{
char * ptr = flg_read ? mb->wr_ptr () : mb->rd_ptr ();
size_t len = flg_read ? mb->length () : (ptr - mb->base ());
if (len > xfer_bytes)
len = xfer_bytes;
ptr -= len;
xfer_bytes -=len;
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("message_block [%d] length=%d:\n"), i, (int)len));
ACE_HEX_DUMP ((LM_DEBUG, ptr, len));
}
}
else if (iovcnt > 0) // iovec
{
iovec *iov = buf_info.get_iov ();
for (int i=0; xfer_bytes != 0 && i < iovcnt; ++i)
{
char * ptr = (char*) iov[i].iov_base;
size_t len = iov[i].iov_len;
if (len > xfer_bytes)
len = xfer_bytes;
ptr -= len;
xfer_bytes -=len;
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("iov[%d] length=%d:\n"), i, (int)len));
ACE_HEX_DUMP ((LM_DEBUG, ptr, len));
}
}
else // simple buffer
{
char *ptr = buf_info.get_buffer ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("buffer length=%d:\n"), (int)xfer_bytes));
ACE_HEX_DUMP ((LM_DEBUG, ptr, xfer_bytes));
}
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("**** end of buffers ****************\n")));
}
示例5: in
void
TAO_ConstantDef_i::value_i (const CORBA::Any &value)
{
CORBA::TypeCode_var my_tc =
this->type_i ();
CORBA::TypeCode_var val_tc = value.type ();
CORBA::Boolean const equal_tc =
my_tc.in ()->equal (val_tc.in ());
if (!equal_tc)
{
return;
}
ACE_Message_Block *mb = 0;
TAO::Any_Impl *impl = value.impl ();
if (impl->encoded ())
{
TAO::Unknown_IDL_Type *unk =
dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
mb = unk->_tao_get_cdr ().steal_contents ();
}
else
{
TAO_OutputCDR out;
impl->marshal_value (out);
TAO_InputCDR in (out);
mb = in.steal_contents ();
}
ACE_Auto_Ptr<ACE_Message_Block> safe (mb);
CORBA::TCKind kind = val_tc->kind ();
switch (kind)
{
// The data for these types will be aligned to an 8-byte
// boundary, while the rd_ptr may not.
case CORBA::tk_double:
case CORBA::tk_ulonglong:
case CORBA::tk_longlong:
case CORBA::tk_longdouble:
mb->rd_ptr (ACE_ptr_align_binary (mb->rd_ptr (),
ACE_CDR::MAX_ALIGNMENT));
break;
default:
break;
}
mb->crunch ();
this->repo_->config ()->set_binary_value (this->section_key_,
"value",
mb->base (),
mb->length ());
}
示例6: result
int
DSession::post_message (void)
{
ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, monitor, this->lock_, -1 );
if (this->get_pending_r_() == 0 &&
this->get_pending_w_() == 0)
return 0; // too late
ACE_Message_Block *mb = 0;
ACE_NEW_RETURN (mb,
ACE_Message_Block (80),
-1);
char str[80];
int len = ACE_OS::snprintf(str,
sizeof(str),
"Message to %s=%d",
this->get_name (),
this->index ());
mb->rd_ptr(mb->base());
mb->wr_ptr(mb->base() + len);
ACE_OS::strcpy(mb->rd_ptr(), str);
TRB_Asynch_User_Result result (this,
ACE_INVALID_HANDLE, // handle
*mb,
0, // bytes requested
0, // offset low
0, // offset high
(const void*) this->index (),
0, // completion key
0, // priority
0); // signal_number
if (this->owner_.task().get_proactor(0)->post_completion (result) < 0)
{
mb->release ();
ACE_ERROR_RETURN((LM_ERROR,
ACE_TEXT ("(%t) %s=%d attempt POST failed\n"),
this->get_name(),
this->index()),
-1);
}
this->post_count_ ++;
return 0;
}
示例7: sizeof
void
displayChain(ACE_Message_Block* chain)
{
//std::cout << "DISPLAYING CHAIN" << std::endl;
for (ACE_Message_Block* current = chain; current; current = current->cont()) {
if (current->length() > 0) {
//std::cout << "DISPLAYING BLOCK" << std::endl;
ACE_TCHAR buffer[4096];
ACE::format_hexdump(current->base(), current->length(), buffer, sizeof(buffer));
std::cout << buffer << std::endl;
}
}
}
示例8:
int
Sender::initiate_write_stream ()
{
if (this->flg_cancel_ != 0)
{
return -1;
}
if (this->get_ref_cnt_w() != 0)
{
return 0; // todo: queue it
}
u_int blksize = this->config().s_blksize();
u_int limit = this->config().xfer_limit();
u_int winsize = this->config().w_size();
if (limit != 0 && this->total_snd_ >= limit)
{
this->shutdown_i ();
return 0;
}
u_long delta = this->total_snd_- this->total_rcv_;
if (delta > winsize)
return 0;
ACE_Message_Block *mb = 0;
ACE_NEW_RETURN (mb,
ACE_Message_Block (blksize+1),
-1);
mb->copy(complete_message);
mb->copy("\0");
mb->wr_ptr(mb->base() + blksize);
if (this->stream_.write (*mb, mb->length ()) == -1)
{
mb->release ();
this->cancel_i();
return -1;
}
this->ref_cnt_w_++;
this->total_w_++;
return 0;
}
示例9: svc
int CSenceManager::svc(void)
{
ACE_Message_Block* mb = NULL;
ACE_Time_Value xtime;
ACE_OS::sleep(1);
while(IsRun())
{
mb = NULL;
//xtime = ACE_OS::gettimeofday() + ACE_Time_Value(0, MAX_MSG_PUTTIMEOUT);
if(getq(mb, 0) == -1)
{
OUR_DEBUG((LM_ERROR,"[CMessageService::svc] PutMessage error errno = [%d].\n", errno));
m_blRun = false;
break;
}
if (mb == NULL)
{
continue;
}
//处理消息
_QueueMessage* pQueueMessage = *((_QueueMessage**)mb->base());
if (! pQueueMessage)
{
OUR_DEBUG((LM_ERROR,"[CMessageService::svc] mb msg == NULL CurrthreadNo=[0]!\n"));
m_objMessageBlockPool.Delete(mb);
m_objMessagePool.Delete(pQueueMessage);
continue;
}
ACE_hrtime_t tvBegin = ACE_OS::gethrtime();
ProcessMessage(pQueueMessage);
m_u4TimeCost += (uint32)(ACE_OS::gethrtime() - tvBegin);
m_u4ProCount++;
if(m_u4ProCount == 6000)
{
OUR_DEBUG((LM_ERROR,"[CMessageService::svc]m_u4ProCount = %d,m_u4TimeCost = %d!\n", m_u4ProCount, m_u4TimeCost));
}
m_objMessageBlockPool.Delete(mb);
m_objMessagePool.Delete(pQueueMessage);
}
OUR_DEBUG((LM_INFO,"[CSenceManager::svc] svc finish!\n"));
return 0;
}
示例10: svc
int CMessageService::svc(void)
{
ACE_Message_Block* mb = NULL;
//稍微休息一下,等一下其他线程再如主循环
ACE_Time_Value tvSleep(0, MAX_MSG_SENDCHECKTIME*MAX_BUFF_1000);
ACE_OS::sleep(tvSleep);
while(IsRun())
{
mb = NULL;
//xtime = ACE_OS::gettimeofday() + ACE_Time_Value(0, MAX_MSG_PUTTIMEOUT);
if(getq(mb, 0) == -1)
{
OUR_DEBUG((LM_ERROR,"[CMessageService::svc] PutMessage error errno = [%d].\n", errno));
m_blRun = false;
break;
}
if(mb == NULL)
{
continue;
}
while(m_emThreadState != THREAD_RUN)
{
//如果模块正在卸载或者重载,线程在这里等加载完毕(等1ms)。
ACE_Time_Value tvsleep(0, 1000);
ACE_OS::sleep(tvsleep);
}
CMessage* msg = *((CMessage**)mb->base());
if(! msg)
{
OUR_DEBUG((LM_ERROR,"[CMessageService::svc] mb msg == NULL CurrthreadNo=[%d]!\n", m_u4ThreadID));
continue;
}
this->ProcessMessage(msg, m_u4ThreadID);
//使用内存池,这块内存不必再释放
}
OUR_DEBUG((LM_INFO,"[CMessageService::svc] svc finish!\n"));
return 0;
}
示例11: svc
virtual int svc ()
{
int stop = 0;
for (ACE_Message_Block *mb; !stop && getq (mb) != -1; )
{
if (mb->msg_type () == ACE_Message_Block::MB_STOP)
{
stop = 1;
}
else
{
ACE_DEBUG ((LM_DEBUG, "%s",mb->base()));
}
put_next (mb);
}
return 0;
}
示例12: send
int ZigbeeSerialportService::send(ZigbeeRequest *req)
{
{
ACE_Message_Block *b = new ACE_Message_Block(req->size());
ACE_OS::memcpy(b->base(), req->base(), req->size());
b->msg_type(ZIGBEE_SERIAL_PORT_CMD_SEND_REQ);
if (task_->message_queue.enqueue_tail(b) == -1 )
{
ACE_DEBUG((LM_DEBUG, "ZigbeeSerialportService faild to input node block into queue\n"));
}
delete req;
}
return 0;
}
示例13:
ACE_Method_Request *
ACE_Activation_Queue::dequeue (ACE_Time_Value *tv)
{
ACE_Message_Block *mb = 0;
// Dequeue the message.
if (this->queue_->dequeue_head (mb, tv) != -1)
{
// Get the next <Method_Request>.
ACE_Method_Request *mr =
reinterpret_cast<ACE_Method_Request *> (mb->base ());
// Delete the message block.
mb->release ();
return mr;
}
else
return 0;
}
示例14: PutMessage
bool CSenceManager::PutMessage(uint32 u4CommandID, _CommandInfo& objCommandInfo)
{
_QueueMessage* pQueueMessage = m_objMessagePool.Create();
if(NULL == pQueueMessage)
{
OUR_DEBUG((LM_INFO,"[CSenceManager::PutMessage] m_objMessagePool not enougth!\n"));
return false;
}
pQueueMessage->m_u4CommandID = u4CommandID;
pQueueMessage->m_objData = objCommandInfo;
ACE_Message_Block* pmb = m_objMessageBlockPool.Create(sizeof(_QueueMessage*));
if(NULL == pmb)
{
OUR_DEBUG((LM_INFO,"[CSenceManager::PutMessage] m_objMessageBlockPool not enougth!\n"));
m_objMessagePool.Delete(pQueueMessage);
return false;
}
_QueueMessage** ppMessage = (_QueueMessage **)pmb->base();
*ppMessage = pQueueMessage;
//判断队列是否是已经最大
int nQueueCount = (int)msg_queue()->message_count();
if(nQueueCount >= (int)QUEUE_COUNT)
{
OUR_DEBUG((LM_ERROR,"[CSenceManager::PutMessage] Queue is Full nQueueCount = [%d].\n", nQueueCount));
m_objMessageBlockPool.Delete(pmb);
m_objMessagePool.Delete(pQueueMessage);
return false;
}
ACE_Time_Value xtime = ACE_OS::gettimeofday();
if(this->putq(pmb, &xtime) == -1)
{
OUR_DEBUG((LM_ERROR,"[CSenceManager::PutMessage] Queue putq error nQueueCount = [%d] errno = [%d].\n", nQueueCount, errno));
m_objMessageBlockPool.Delete(pmb);
m_objMessagePool.Delete(pQueueMessage);
return false;
}
return true;
}
示例15:
int
JAWS_THYBRID_Concurrency::getq (JAWS_Protocol_Handler *&ph)
{
ph = 0;
JAWS_CONCURRENCY_TASK *task = this;
if (this->shutdown_task_ && task->msg_queue ()->message_count () == 0)
return -1;
int getting = ++(this->getting_);
if (getting > this->min_number_of_threads_)
{
if (task->msg_queue ()->message_count () == 0)
{
--(this->getting_);
return -1;
}
}
ACE_Message_Block *mb = 0;
int result = task->getq (mb);
if (result != -1)
{
ph = (JAWS_Protocol_Handler *) mb->base ();
if (ph == 0)
{
// Shutdown this task;
this->shutdown_task_ = 1;
if (this->getting_ > 1)
{
task->putq (mb);
result = -1;
}
}
}
--(this->getting_);
return result;
}