本文整理汇总了C++中ACE_Message_Block::set_flags方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Message_Block::set_flags方法的具体用法?C++ ACE_Message_Block::set_flags怎么用?C++ ACE_Message_Block::set_flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Message_Block
的用法示例。
在下文中一共展示了ACE_Message_Block::set_flags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
/*!
* @brief Allocate and return a new empty message block of size \a span_size
* mimicking parameters of \a mb.
*
* This function allocates a new aligned message block using the same
* allocators and flags as found in \a mb. The size of the new message
* block is at least \a span_size; the size may be adjusted up in order
* to accomodate alignment requirements and still fit \a span_size bytes
* into the aligned buffer.
*
* @param mb message block whose parameters should be mimicked
* @param span_size size of the new message block (will be adjusted for proper
* alignment)
* @return an aligned message block with rd_ptr sitting at correct
* alignment spot, 0 on failure
*/
static ACE_Message_Block*
clone_mb_nocopy_size (ACE_Message_Block *mb, size_t span_size)
{
// Calculate the required size of the cloned block with alignment
size_t const aligned_size = ACE_CDR::first_size (span_size + ACE_CDR::MAX_ALIGNMENT);
// Get the allocators
ACE_Allocator *data_allocator = 0;
ACE_Allocator *data_block_allocator = 0;
ACE_Allocator *message_block_allocator = 0;
mb->access_allocators (data_allocator,
data_block_allocator,
message_block_allocator);
// Create a new Message Block
ACE_Message_Block *nb = 0;
ACE_NEW_MALLOC_RETURN (nb,
static_cast<ACE_Message_Block*> (
message_block_allocator->malloc (
sizeof (ACE_Message_Block))),
ACE_Message_Block(aligned_size,
mb->msg_type(),
mb->cont(),
0, //we want the data block created
data_allocator,
mb->locking_strategy(),
mb->msg_priority(),
mb->msg_execution_time (),
mb->msg_deadline_time (),
data_block_allocator,
message_block_allocator),
0);
ACE_CDR::mb_align (nb);
// Copy the flags over, but be SURE to clear the DONT_DELETE flag, since
// we just dynamically allocated the two things.
nb->set_flags (mb->flags());
nb->clr_flags (ACE_Message_Block::DONT_DELETE);
return nb;
}
示例2: 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;
}