Queued_Data.cpp File Reference

#include "tao/Queued_Data.h"
#include "tao/debug.h"
#include "ace/Log_Msg.h"
#include "ace/Malloc_Base.h"

Include dependency graph for Queued_Data.cpp:

Include dependency graph

Go to the source code of this file.

Functions

TAO_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_Message_Block
clone_mb_nocopy_size (ACE_Message_Block *mb, size_t span_size)
 Allocate and return a new empty message block of size span_size mimicking parameters of mb.


Function Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Message_Block* clone_mb_nocopy_size ACE_Message_Block mb,
size_t  span_size
[static]
 

Allocate and return a new empty message block of size span_size mimicking parameters of mb.

This function allocates a new aligned message block using the same allocators and flags as found in mb. The size of the new message block is at least span_size; the size may be adjusted up in order to accomodate alignment requirements and still fit span_size bytes into the aligned buffer.

Parameters:
mb message block whose parameters should be mimicked
span_size size of the new message block (will be adjusted for proper alignment)
Returns:
an aligned message block with rd_ptr sitting at correct alignment spot, 0 on failure

Definition at line 36 of file Queued_Data.cpp.

References ACE_Message_Block::access_allocators(), ACE_Message_Block, ACE_NEW_MALLOC_RETURN, ACE_Message_Block::clr_flags(), ACE_Message_Block::cont(), ACE_CDR::first_size(), ACE_Message_Block::flags(), ACE_Message_Block::locking_strategy(), ACE_Allocator::malloc(), ACE_CDR::mb_align(), ACE_Message_Block::msg_deadline_time(), ACE_Message_Block::msg_execution_time(), ACE_Message_Block::msg_priority(), ACE_Message_Block::msg_type(), and ACE_Message_Block::set_flags().

Referenced by TAO_Queued_Data::consolidate().

00037 {
00038   // Calculate the required size of the cloned block with alignment
00039   size_t const aligned_size = ACE_CDR::first_size (span_size + ACE_CDR::MAX_ALIGNMENT);
00040 
00041   // Get the allocators
00042   ACE_Allocator *data_allocator = 0;
00043   ACE_Allocator *data_block_allocator = 0;
00044   ACE_Allocator *message_block_allocator = 0;
00045   mb->access_allocators (data_allocator,
00046                          data_block_allocator,
00047                          message_block_allocator);
00048 
00049   // Create a new Message Block
00050   ACE_Message_Block *nb = 0;
00051   ACE_NEW_MALLOC_RETURN (nb,
00052                          static_cast<ACE_Message_Block*> (
00053                                          message_block_allocator->malloc (
00054                                            sizeof (ACE_Message_Block))),
00055                          ACE_Message_Block(aligned_size,
00056                                            mb->msg_type(),
00057                                            mb->cont(),
00058                                            0, //we want the data block created
00059                                            data_allocator,
00060                                            mb->locking_strategy(),
00061                                            mb->msg_priority(),
00062                                            mb->msg_execution_time (),
00063                                            mb->msg_deadline_time (),
00064                                            data_block_allocator,
00065                                            message_block_allocator),
00066                          0);
00067 
00068   ACE_CDR::mb_align (nb);
00069 
00070   // Copy the flags over, but be SURE to clear the DONT_DELETE flag, since
00071   // we just dynamically allocated the two things.
00072   nb->set_flags (mb->flags());
00073   nb->clr_flags (ACE_Message_Block::DONT_DELETE);
00074 
00075   return nb;
00076 }


Generated on Sun Jan 27 13:12:36 2008 for TAO by doxygen 1.3.6