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 "tao/Queued_Data.inl"

Include dependency graph for Queued_Data.cpp:

Go to the source code of this file.

Functions

static 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

static 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 34 of file Queued_Data.cpp.

References ACE_NEW_MALLOC_RETURN, ACE_Message_Block::clr_flags(), ACE_Message_Block::DONT_DELETE, ACE_CDR::first_size(), ACE_Allocator::malloc(), ACE_CDR::MAX_ALIGNMENT, ACE_CDR::mb_align(), and ACE_Message_Block::set_flags().

Referenced by TAO_Queued_Data::consolidate().

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


Generated on Tue Feb 2 17:38:46 2010 for TAO by  doxygen 1.4.7