本文整理汇总了C++中ACE_Message_Block::total_length方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Message_Block::total_length方法的具体用法?C++ ACE_Message_Block::total_length怎么用?C++ ACE_Message_Block::total_length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Message_Block
的用法示例。
在下文中一共展示了ACE_Message_Block::total_length方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getchain
void
runTest(const Values& expected, const ArrayValues& expectedArray,
bool swap, Serializer::Alignment align)
{
ACE_Message_Block* testchain = getchain(sizeof(chaindefs)/sizeof(chaindefs[0]), chaindefs);
const char* out = swap ? "" : "OUT";
std::cout << std::endl << "STARTING INSERTION OF SINGLE VALUES WITH" << out << " SWAPPING" << std::endl;
insertions(testchain, expected, swap, align);
size_t bytesWritten = testchain->total_length();
std::cout << std::endl << "BYTES WRITTEN: " << bytesWritten << std::endl;
displayChain(testchain);
std::cout << "EXTRACTING SINGLE VALUES WITH" << out << " SWAPPING" << std::endl;
Values observed = {0, 0, 0, 0, 0, 0, 0, 0, 0,
ACE_CDR_LONG_DOUBLE_INITIALIZER, 0, 0, 0
#ifndef OPENDDS_SAFETY_PROFILE
, ""
#endif
#ifdef DDS_HAS_WCHAR
, 0
#ifndef OPENDDS_SAFETY_PROFILE
, L""
#endif
#endif
};
extractions(testchain, observed, swap, align);
if (testchain->total_length()) {
std::cout << "ERROR: BYTES READ != BYTES WRITTEN" << std::endl;
failed = true;
}
checkValues(expected, observed);
#ifdef DDS_HAS_WCHAR
CORBA::wstring_free(observed.wstringValue);
#ifndef OPENDDS_SAFETY_PROFILE
CORBA::string_free(observed.stringValue);
#endif
#endif
testchain->release();
testchain = getchain(sizeof(chaindefs)/sizeof(chaindefs[0]), chaindefs);
std::cout << std::endl << "STARTING INSERTION OF ARRAY VALUES WITH" << out << " SWAPPING" << std::endl;
array_insertions(testchain, expectedArray, ARRAYSIZE, swap, align);
bytesWritten = testchain->total_length();
std::cout << std::endl << "BYTES WRITTEN: " << bytesWritten << std::endl;
displayChain(testchain);
std::cout << "EXTRACTING ARRAY VALUES WITH" << out << " SWAPPING" << std::endl;
ArrayValues observedArray;
array_extractions(testchain, observedArray, ARRAYSIZE, swap, align);
if (testchain->total_length()) {
std::cout << "ERROR: BYTES READ != BYTES WRITTEN" << std::endl;
failed = true;
}
checkArrayValues(expectedArray, observedArray);
testchain->release();
}
示例2:
CmResult COFP10PacketOutMsg::AppendPacketData(ACE_Message_Block &aData)
{
if (m_PacketData != nullptr)
{
m_PacketData->append(aData.clone());
}
else
{
m_PacketData = aData.clone();
}
m_wDataLen += aData.total_length();
return CM_OK;
}
示例3: SendInternal
void ProactorService::SendInternal(char* pBuffer, int bufferSize)
{
ACE_Message_Block* pBlock = NULL;
ACE_NEW_NORETURN(pBlock, ACE_Message_Block(bufferSize));
pBlock->copy((const char*)pBuffer, bufferSize);
if(NULL == pBlock->cont())
{
m_AsyncWriter.write(*pBlock, pBlock->length());
}
else
{
m_AsyncWriter.writev(*pBlock, pBlock->total_length());
}
}
示例4:
void
Sender::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result)
{
ACE_Message_Block *mb = &result.message_block ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Sender::handle_write_stream - wrote %d bytes\n"),
result.bytes_transferred ()));
if (result.error () == 0 && result.bytes_transferred () != 0)
// verify sent all
ACE_TEST_ASSERT (0 == mb->total_length ());
else
ACE_TEST_ASSERT (0);
free_chunks_chain (mb);
--this->io_count_;
this->check_destroy ();
}
示例5: if
void
Receiver::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result)
{
ACE_Message_Block *mb = &result.message_block ();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Receiver::handle_read_stream - (%s) read %d\n"),
this->odd_ ? ACE_TEXT ("ODD ") : ACE_TEXT ("EVEN"),
result.bytes_transferred ()));
// Transfer only complete chunks to the writer.
// Save last partial chunk for the next call.
// On disconnect (error or 0 transferred), transfer whatever we have.
// at this stage there should not be anything there
ACE_TEST_ASSERT (!this->partial_chunk_);
// first, remove the empty chunks
remove_empty_chunks (mb);
if (mb && Receiver::writer_)
{ // there's something to write, and who to write to
// write everything or only complete chunks?
// write everything - when no new bytes were transferred
int write_everything = 0;
if (!result.bytes_transferred ())
write_everything = 1;
if (write_everything)
Receiver::writer_->handle_read_chunks_chain (mb,
this->odd_ ? ODD : EVEN);
else
{ // filter out the partial chunk at the end (if present)
// and save it for later before writing the full chunks
// have this->partial_chunk_ point to the last chunk in the chain
size_t last_index = last_chunk (mb, this->partial_chunk_);
if (this->partial_chunk_ &&
this->partial_chunk_->length () < chunk_size)
{ // found partial chunk at end of chain
// detach it from the chain
if (last_index > 1) // chain bigger than 1
{
ACE_Message_Block *pre_last = mb;
for (size_t index = 1; index < last_index - 1; ++index)
pre_last = pre_last->cont ();
// detach partial chunk from chain
pre_last->cont (0);
}
else
// chain in length of 1 - so we need to zero mb
mb = 0;
}
else // last is a full chunk, so hand it over with the rest
this->partial_chunk_ = 0;
// transfer (if there's anything left)
if (mb && mb->total_length ())
Receiver::writer_->handle_read_chunks_chain (
mb,
this->odd_ ? ODD : EVEN);
// initiate more reads only if no error
if (!result.error ())
this->initiate_read_stream ();
else
ACE_TEST_ASSERT (0);
}
}
else if (mb && !Receiver::writer_)
// no one to write to
free_chunks_chain (mb);
--this->io_count_;
this->check_destroy ();
}