本文整理汇总了C++中ACE_Message_Block::wr_ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Message_Block::wr_ptr方法的具体用法?C++ ACE_Message_Block::wr_ptr怎么用?C++ ACE_Message_Block::wr_ptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Message_Block
的用法示例。
在下文中一共展示了ACE_Message_Block::wr_ptr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
Supplier::svc (void)
{
ACE_Message_Block *mb = 0;
// Send one message for each letter of the alphabet, then send an empty
// message to mark the end.
for (const char *c = ACE_ALPHABET; *c != '\0'; c++)
{
// Allocate a new message.
char d[2];
d[0] = *c;
d[1] = '\0';
ACE_NEW_RETURN (mb,
ACE_Message_Block (2),
-1);
ACE_OS::strcpy (mb->wr_ptr (), d);
mb->wr_ptr (2);
if (this->put_next (mb) == -1)
ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%t) %p\n"),
ACE_TEXT ("put_next")));
}
ACE_NEW_RETURN(mb, ACE_Message_Block, -1);
if (this->put_next (mb) == -1)
ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("put_next")));
return 0;
}
示例2: 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);
}
示例3: put
static ACE_Message_Block * put( const T& t, unsigned long msg_type = 0 ) {
ACE_Message_Block * mb = new ACE_Message_Block( sizeof(T) );
*reinterpret_cast<T*>( mb->wr_ptr() ) = t;
mb->wr_ptr( sizeof(T) );
if ( msg_type >= ACE_Message_Block::MB_USER )
mb->msg_type( msg_type );
return mb;
}
示例4: sendData
int ScadaClientMgr::sendData(char* data,int length)
{
ACE_Message_Block * mb = new ACE_Message_Block(length);
ACE_OS::memcpy(mb->wr_ptr(),data,length);
mb->wr_ptr(length);
return m_tcpClient.send(mb);
}
示例5: io_result
int
JAWS_IO_Reactive_Transmit::handle_output_source (ACE_HANDLE handle)
{
ACE_Message_Block *mb = this->source_buf_;
// Try to read data into the mb if data is still available.
if (mb->space () && this->source_ != ACE_INVALID_HANDLE)
{
ssize_t count;
count = ACE_OS::read (this->source_, mb->wr_ptr (), mb->space ());
if (count < 0)
{
this->source_ = ACE_INVALID_HANDLE;
this->source_buf_ = 0;
if (this->bytes_ == 0)
{
JAWS_Event_Result io_result ( 0
, JAWS_Event_Result::JE_ERROR
, JAWS_Event_Result::JE_TRANSMIT_FAIL
);
this->io_result_ = io_result;
}
else if (this->bytes_ > 0)
{
JAWS_Event_Result io_result ( this->bytes_
, JAWS_Event_Result::JE_ERROR
, JAWS_Event_Result::JE_TRANSMIT_SHORT
);
this->io_result_ = io_result;
}
return -1;
}
else if (count == 0)
this->source_ = ACE_INVALID_HANDLE;
else
mb->wr_ptr (count);
}
int result = 0;
if (mb->length () > 0)
result = this->handle_output_mb (handle, mb);
if (result < 0)
{
this->source_ = ACE_INVALID_HANDLE;
this->source_buf_ = 0;
}
else if (mb == 0 && this->source_ == ACE_INVALID_HANDLE)
this->source_buf_ = 0;
else
this->source_buf_->crunch ();
return result;
}
示例6:
static int
issue_aio_calls (void)
{
// Setup AIOCB.
aiocb1.aio_fildes = file_handle;
aiocb1.aio_offset = 0;
aiocb1.aio_buf = mb1.wr_ptr ();
aiocb1.aio_nbytes = BUFSIZ;
aiocb1.aio_reqprio = 0;
aiocb1.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
aiocb1.aio_sigevent.sigev_signo = SIGRTMIN;
aiocb1.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb1;
// Fire off the aio read.
if (aio_read (&aiocb1) == -1)
// Queueing failed.
ACE_ERROR_RETURN ((LM_ERROR, "Error: %p\n",
"Asynch_Read_Stream: aio_read queueing failed"),
-1);
// Setup AIOCB.
aiocb2.aio_fildes = file_handle;
aiocb2.aio_offset = BUFSIZ + 1;
aiocb2.aio_buf = mb2.wr_ptr ();
aiocb2.aio_nbytes = BUFSIZ;
aiocb2.aio_reqprio = 0;
aiocb2.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
aiocb2.aio_sigevent.sigev_signo = SIGRTMIN;
aiocb2.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb2;
// Fire off the aio read.
if (aio_read (&aiocb2) == -1)
// Queueing failed.
ACE_ERROR_RETURN ((LM_ERROR, "Error: %p\n",
"Asynch_Read_Stream: aio_read queueing failed"),
-1);
// Setup sigval.
aiocb3.aio_fildes = ACE_INVALID_HANDLE;
aiocb3.aio_offset = 0;
aiocb3.aio_buf = 0;
aiocb3.aio_nbytes = 0;
aiocb3.aio_reqprio = 0;
aiocb3.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
aiocb3.aio_sigevent.sigev_signo = SIGRTMIN;
aiocb3.aio_sigevent.sigev_value.sival_ptr = (void *) &aiocb3;
sigval value;
value.sival_ptr = reinterpret_cast<void *> (&aiocb3);
// Queue this one for completion right now.
if (sigqueue (ACE_OS::getpid (), SIGRTMIN, value) == -1)
// Queueing failed.
ACE_ERROR_RETURN ((LM_ERROR,
"Error: %p\n", "sigqueue"),
-1);
return 0;
}
示例7: get_file
//get file and store it into ACE message block.
bool ZIP_Wrapper::get_file (char* archive_path, char* filename,
ACE_Message_Block &file)
{
bool return_code = true;
unzFile uf=0;
uf = unzOpen(archive_path);
/* locate the desired file in the zip file and set it as current file*/
int j=unzLocateFile(uf, filename, 0);
if (j==UNZ_END_OF_LIST_OF_FILE)
{
DANCE_ERROR (DANCE_LOG_ERROR,
(LM_DEBUG, ACE_TEXT("File not found in zip archive")));
return false;
}
else if (j==UNZ_OK)
{
int k=unzOpenCurrentFile(uf);
if (k!=UNZ_OK)
{
DANCE_ERROR (DANCE_LOG_ERROR,
(LM_DEBUG, ACE_TEXT("Error in opening the current")
ACE_TEXT(" file using unzOpenCurrentFile")));
return false;
}
else
{
int num_read = 0;
ACE_Message_Block* head = &file;
//read the file into the ACE_Message_Block
do
{
if (head->space () == 0)
{
ACE_Message_Block* next = 0;
ACE_NEW_RETURN (next, ACE_Message_Block (BUFSIZ), false);
head = head->cont ();
}
num_read = unzReadCurrentFile(archive_path, head->wr_ptr(),
head->space());
if (num_read > 0)
head->wr_ptr (num_read);
} while (num_read > 0);
if (num_read < 0)
return_code = false;
unzCloseCurrentFile(uf);
unzClose(uf);
return return_code;
}
}
return return_code;
}
示例8: produce_item
void produce_item (int item)
{
psema_.acquire ();
ACE_Message_Block *mb
= new ACE_Message_Block (sizeof (int),
ACE_Message_Block::MB_DATA);
ACE_OS::memcpy (mb->wr_ptr (), &item, sizeof item);
mb->wr_ptr (sizeof (int));
this->consumer_.putq (mb);
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Produced %d\n"), item));
csema_.release();
}
示例9:
int
JAWS_Parse_Headers::parse_header_name (JAWS_Header_Info *info,
ACE_Message_Block &mb)
{
char *p = mb.rd_ptr ();
char *q;
q = this->skipset (":\n", p, mb.wr_ptr ());
if (q == mb.wr_ptr ())
{
// no more progress can be made until we find a ':'
return 1;
}
if (*q != '\n' && q == p)
{
// Ignore empty header type names
info->finish_last_header_value ();
info->create_next_header_value (0);
info->end_of_line (0);
mb.rd_ptr (q+1);
return 0;
}
if (*q == '\n')
{
// ignore this line
mb.rd_ptr (q+1);
if (q == p || ((q-1) == p && q[-1] == '\r'))
{
// blank line means end of headers
info->finish_last_header_value ();
info->create_next_header_value (0);
info->end_of_headers (1);
if (mb.rd_ptr () == mb.wr_ptr ())
mb.crunch ();
return 1;
}
// not a blank line, but no ':', so ignore it
info->finish_last_header_value ();
info->create_next_header_value (0);
return 0;
}
// otherwise, we have a header type name!
*q = '\0';
info->create_next_header_value (p);
info->end_of_line (0);
mb.rd_ptr (q+1);
return 0;
}
示例10: Make_Common_Dispose_Client_WorkTread_Message
int Make_Common_Dispose_Client_WorkTread_Message(uint16 u2CommandID, uint32 u4ServerID, ACE_Message_Block* pmblk, ACE_INET_Addr& AddrRemote)
{
//组织数据
CMessage* pMessage = App_MessageServiceGroup::instance()->CreateMessage(u4ServerID, CONNECT_IO_TCP);
if (NULL == pMessage)
{
//放入消息框架失败
OUR_DEBUG((LM_ERROR, "[CConnectClient::SendMessageGroup] ConnectID = %d CreateMessage fail.\n", u4ServerID));
App_MessageBlockManager::instance()->Close(pmblk);
return -1;
}
else
{
ACE_Message_Block* pMBBHead = App_MessageBlockManager::instance()->Create(sizeof(uint32));
if (NULL == pMBBHead)
{
OUR_DEBUG((LM_ERROR, "[CConnectClient::SendMessageGroup] ConnectID = %d pMBBHead fail.\n", u4ServerID));
App_MessageBlockManager::instance()->Close(pmblk);
return -1;
}
//添加消息包头
uint32 u4PacketLen = (uint32)pmblk->length();
memcpy_safe((char*)&u4PacketLen, sizeof(uint32), pMBBHead->wr_ptr(), sizeof(uint32));
pMBBHead->wr_ptr(sizeof(uint32));
sprintf_safe(pMessage->GetMessageBase()->m_szListenIP, MAX_BUFF_20, "%s", AddrRemote.get_host_addr());
sprintf_safe(pMessage->GetMessageBase()->m_szIP, MAX_BUFF_20, "127.0.0.1");
pMessage->GetMessageBase()->m_u2Cmd = u2CommandID;
pMessage->GetMessageBase()->m_u4ConnectID = u4ServerID;
pMessage->GetMessageBase()->m_u4ListenPort = (uint32)AddrRemote.get_port_number();
pMessage->GetMessageBase()->m_tvRecvTime = ACE_OS::gettimeofday();
pMessage->GetMessageBase()->m_u1ResouceType = RESOUCE_FROM_SERVER;
pMessage->GetMessageBase()->m_u4HeadSrcSize = sizeof(uint32);
pMessage->GetMessageBase()->m_u4BodySrcSize = u4PacketLen;
pMessage->SetPacketHead(pMBBHead);
pMessage->SetPacketBody(pmblk);
//将要处理的消息放入消息处理线程
if (false == App_MessageServiceGroup::instance()->PutMessage(pMessage))
{
OUR_DEBUG((LM_ERROR, "[CConnectClient::SendMessageGroup] App_MessageServiceGroup::instance()->PutMessage Error.\n"));
App_MessageServiceGroup::instance()->DeleteMessage(u4ServerID, pMessage);
return -1;
}
}
return 0;
}
示例11: put_config
int GadgetInstrumentationStreamController::put_config(const char* config)
{
size_t l = std::strlen(config);
ACE_Message_Block* mb = new ACE_Message_Block(l+1);
memcpy(mb->wr_ptr(),config,l+1);
mb->wr_ptr(l+1);
mb->set_flags(Gadget::GADGET_MESSAGE_CONFIG);
if (stream_.put(mb) == -1) {
GERROR("Failed to put configuration on stream, too long wait, %d\n", ACE_OS::last_error () == EWOULDBLOCK);
mb->release();
return GADGET_FAIL;
}
return GADGET_OK;
}
示例12: paceData
void BulkDataSenderPerfImpl::paceData()
{
//ACS_TRACE("BulkDataSenderPerfImpl::paceData");
int size;
CORBA::ULong flowNumber;
size = 300000000;
try
{
ACE_Message_Block *mb;
mb = new ACE_Message_Block(size);
for (CORBA::Long j = 0; j < (size-1); j++)
{
*mb->wr_ptr()='d';
mb->wr_ptr(sizeof(char));
}
*mb->wr_ptr()='\0';
mb->wr_ptr(sizeof(char));
flowNumber = 1;
getSender()->sendData(flowNumber, mb);
//ACS_SHORT_LOG ((LM_INFO,"flow 1 length sent data = %d", mb->length()));
mb->release();
}
catch (AVInvalidFlowNumberExImpl & ex)
{
ACS_SHORT_LOG((LM_INFO,"BulkDataSenderPerfImpl::paceData AVInvalidFlowNumberExImpl exception catched !"));
AVPaceDataErrorExImpl err = AVPaceDataErrorExImpl(ex,__FILE__,__LINE__,"BulkDataSenderPerfImpl::paceData");
throw err.getAVPaceDataErrorEx();
}
catch (AVSendFrameErrorExImpl & ex)
{
ACS_SHORT_LOG((LM_INFO,"BulkDataSenderPerfImpl::paceData AVSendFrameErrorExImpl exception catched !"));
AVPaceDataErrorExImpl err = AVPaceDataErrorExImpl(ex,__FILE__,__LINE__,"BulkDataSenderPerfImpl::paceData");
throw err.getAVPaceDataErrorEx();
}
catch (...)
{
ACS_SHORT_LOG((LM_INFO,"BulkDataSenderPerfImpl::paceData UNKNOWN exception"));
AVPaceDataErrorExImpl err = AVPaceDataErrorExImpl(__FILE__,__LINE__,"BulkDataSenderPerfImpl::paceData");
throw err.getAVPaceDataErrorEx();
}
}
示例13: consumer
static void *
producer (void *args)
{
ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue =
reinterpret_cast<ACE_Message_Queue<ACE_MT_SYNCH> *> (args);
ACE_Message_Block *mb = 0;
for (const char *c = ACE_ALPHABET; *c != '\0'; c++)
{
++message_count;
// Allocate a new message
ACE_NEW_RETURN (mb,
ACE_Message_Block (1),
0);
*mb->wr_ptr () = *c;
// Set the priority.
mb->msg_priority (message_count);
mb->wr_ptr (1);
// Enqueue in priority order.
if (msg_queue->enqueue_prio (mb) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%t) %p\n"),
ACE_TEXT ("put_next")),
0);
}
// Now send a 0-sized shutdown message to the other thread
ACE_NEW_RETURN (mb,
ACE_Message_Block ((size_t) 0),
0);
if (msg_queue->enqueue_tail (mb) == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%t) %p\n"),
ACE_TEXT ("put_next")));
++message_count;
// Now read all the items out in priority order (i.e., ordered by
// the size of the lines!).
consumer (msg_queue);
return 0;
}
示例14:
void
JAWS_Synch_IO_No_Cache::read (ACE_Message_Block &mb, int size)
{
ACE_SOCK_Stream stream;
stream.set_handle (this->handle_);
int result = stream.recv (mb.wr_ptr (), size);
if (result <= 0)
this->handler_->read_error ();
else
{
mb.wr_ptr (result);
this->handler_->read_complete (mb);
}
}
示例15:
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;
}