Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Data_Block Class Reference

Stores the data payload that is accessed via one or more <ACE_Message_Block>s. More...

#include <Message_Block.h>

Inheritance diagram for ACE_Data_Block:

Inheritance graph
[legend]
Collaboration diagram for ACE_Data_Block:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Data_Block (void)
 Default "do-nothing" constructor. More...

 ACE_Data_Block (size_t size, ACE_Message_Block::ACE_Message_Type msg_type, const char *msg_data, ACE_Allocator *allocator_strategy, ACE_Lock *locking_strategy, ACE_Message_Block::Message_Flags flags, ACE_Allocator *data_block_allocator)
 Initialize. More...

virtual ~ACE_Data_Block (void)
 Delete all the resources held in the message. More...

ACE_Message_Block::ACE_Message_Type msg_type (void) const
 Get type of the message. More...

void msg_type (ACE_Message_Block::ACE_Message_Type type)
 Set type of the message. More...

char * base (void) const
 Get message data pointer. More...

void base (char *data, size_t size, ACE_Message_Block::Message_Flags mflags=ACE_Message_Block::DONT_DELETE)
 Set message data pointer (doesn't reallocate). More...

char * end (void) const
 Return a pointer to 1 past the end of the allocated data in a message. More...

char * mark (void) const
size_t size (void) const
 Get the total amount of allotted space in the message. The amount of allotted space may be less than allocated space. More...

int size (size_t length)
 Set the total amount of space in the message. Returns 0 if successful, else -1. More...

size_t capacity (void) const
 Get the total amount of allocated space. More...

virtual ACE_Data_Block * clone (ACE_Message_Block::Message_Flags mask=0) const
virtual ACE_Data_Block * clone_nocopy (ACE_Message_Block::Message_Flags mask=0) const
ACE_Data_Block * duplicate (void)
 Return a "shallow" copy that increments our reference count by 1. More...

ACE_Data_Block * release (ACE_Lock *lock=0)
ACE_Message_Block::Message_Flags set_flags (ACE_Message_Block::Message_Flags more_flags)
 Bitwise-or the <more_flags> into the existing message flags and return the new value. More...

ACE_Message_Block::Message_Flags clr_flags (ACE_Message_Block::Message_Flags less_flags)
 Clear the message flag bits specified in <less_flags> and return the new value. More...

ACE_Message_Block::Message_Flags flags (void) const
 Get the current message flags. More...

ACE_Allocatorallocator_strategy (void) const
 Obtain the allocator strategy. More...

ACE_Locklocking_strategy (void)
 Get the locking strategy. More...

ACE_Locklocking_strategy (ACE_Lock *)
 Set a new locking strategy and return the hold one. More...

void dump (void) const
 Dump the state of an object. More...

int reference_count (void) const
 Get the current reference count. More...

ACE_Allocatordata_block_allocator (void) const
 Get the allocator used to create this object. More...


Protected Methods

ACE_Data_Block * release_i (void)
 Internal release implementation. More...

ACE_Data_Block * release_no_delete (ACE_Lock *lock)

Protected Attributes

ACE_Message_Block::ACE_Message_Type type_
 Type of message. More...

size_t cur_size_
 Current size of message block. More...

size_t max_size_
 Total size of buffer. More...

ACE_Message_Block::Message_Flags flags_
 Misc flags (e.g., DONT_DELETE and USER_FLAGS). More...

char * base_
 Pointer To beginning of message payload. More...

ACE_Allocatorallocator_strategy_
ACE_Locklocking_strategy_
int reference_count_
ACE_Allocatordata_block_allocator_
 The allocator use to destroy ourselves. More...


Private Methods

ACE_Data_Block & operator= (const ACE_Data_Block &)
 ACE_Data_Block (const ACE_Data_Block &)

Friends

class ACE_Message_Block

Detailed Description

Stores the data payload that is accessed via one or more <ACE_Message_Block>s.

This data structure is reference counted to maximize sharing. It also contains the <locking_strategy_> (which protects the reference count from race conditions in concurrent programs) and the <allocation_strategy_> (which determines what memory pool is used to allocate the memory).

Definition at line 670 of file Message_Block.h.


Constructor & Destructor Documentation

ACE_Data_Block::ACE_Data_Block void   
 

Default "do-nothing" constructor.

Definition at line 286 of file Message_Block.cpp.

References ACE_ALLOCATOR, ACE_FUNCTION_TIMEPROBE, ACE_TRACE, and ACE_Allocator::instance.

Referenced by clone_nocopy.

00287   : type_ (ACE_Message_Block::MB_DATA),
00288     cur_size_ (0),
00289     max_size_ (0),
00290     flags_ (ACE_Message_Block::DONT_DELETE),
00291     base_ (0),
00292     allocator_strategy_ (0),
00293     locking_strategy_ (0),
00294     reference_count_ (1),
00295     data_block_allocator_ (0)
00296 {
00297   ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
00298   ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR1_ENTER);
00299 
00300   ACE_ALLOCATOR (this->allocator_strategy_,
00301                  ACE_Allocator::instance ());
00302 
00303   ACE_ALLOCATOR (this->data_block_allocator_,
00304                  ACE_Allocator::instance ());
00305 }

ACE_Data_Block::ACE_Data_Block size_t    size,
ACE_Message_Block::ACE_Message_Type    msg_type,
const char *    msg_data,
ACE_Allocator   allocator_strategy,
ACE_Lock   locking_strategy,
ACE_Message_Block::Message_Flags    flags,
ACE_Allocator   data_block_allocator
 

Initialize.

Definition at line 307 of file Message_Block.cpp.

References ACE_ALLOCATOR, ACE_FUNCTION_TIMEPROBE, ACE_Message_Block::ACE_Message_Type, ACE_TRACE, allocator_strategy_, cur_size_, data_block_allocator_, ACE_Allocator::instance, max_size_, ACE_Message_Block::Message_Flags, and size.

00314   : type_ (msg_type),
00315     cur_size_ (0),          // Reset later if memory alloc'd ok
00316     max_size_ (0),
00317     flags_ (flags),
00318     base_ ((char *) msg_data),
00319     allocator_strategy_ (allocator_strategy),
00320     locking_strategy_ (locking_strategy),
00321     reference_count_ (1),
00322     data_block_allocator_ (data_block_allocator)
00323 {
00324   ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
00325   ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR2_ENTER);
00326 
00327   // If the user didn't pass one in, let's use the
00328   // <ACE_Allocator::instance>.
00329   if (this->allocator_strategy_ == 0)
00330     ACE_ALLOCATOR (this->allocator_strategy_,
00331                    ACE_Allocator::instance ());
00332 
00333   if (this->data_block_allocator_ == 0)
00334     ACE_ALLOCATOR (this->data_block_allocator_,
00335                    ACE_Allocator::instance ());
00336 
00337   if (msg_data == 0)
00338     ACE_ALLOCATOR (this->base_,
00339                    (char *) this->allocator_strategy_->malloc (size));
00340     // ACE_ALLOCATOR returns on alloc failure...
00341 
00342   // The memory is legit, whether passed in or allocated, so set the size.
00343   this->cur_size_ = this->max_size_ = size;
00344 }

ACE_Data_Block::~ACE_Data_Block void    [virtual]
 

Delete all the resources held in the message.

Definition at line 696 of file Message_Block.cpp.

References ACE_ASSERT, ACE_BIT_DISABLED, allocator_strategy_, base_, ACE_Message_Block::DONT_DELETE, ACE_Allocator::free, and reference_count_.

00697 {
00698   // Sanity check...
00699   ACE_ASSERT (this->reference_count_ <= 1);
00700 
00701   // Just to be safe...
00702   this->reference_count_ = 0;
00703 
00704   if (ACE_BIT_DISABLED (this->flags_,
00705                         ACE_Message_Block::DONT_DELETE))
00706     {
00707       this->allocator_strategy_->free ((void *) this->base_);
00708       this->base_ = 0;
00709     }
00710 }

ACE_Data_Block::ACE_Data_Block const ACE_Data_Block &    [private]
 


Member Function Documentation

ACE_INLINE ACE_Allocator * ACE_Data_Block::allocator_strategy void    const
 

Obtain the allocator strategy.

Definition at line 471 of file Message_Block.i.

References ACE_TRACE, and allocator_strategy_.

Referenced by ACE_Locked_Data_Block::clone_nocopy.

00472 {
00473   ACE_TRACE ("ACE_Data_Block::allocator_strategy");
00474   return this->allocator_strategy_;
00475 }

void ACE_Data_Block::base char *    data,
size_t    size,
ACE_Message_Block::Message_Flags    mflags = ACE_Message_Block::DONT_DELETE
 

Set message data pointer (doesn't reallocate).

Definition at line 1179 of file Message_Block.cpp.

References ACE_BIT_DISABLED, allocator_strategy_, base_, cur_size_, ACE_Message_Block::DONT_DELETE, flags_, ACE_Allocator::free, max_size_, and ACE_Message_Block::Message_Flags.

01182 {
01183   if (ACE_BIT_DISABLED (this->flags_,
01184                         ACE_Message_Block::DONT_DELETE))
01185     this->allocator_strategy_->free (this->base_);
01186   this->max_size_ = msg_length;
01187   this->cur_size_ = msg_length;
01188   this->base_ = msg_data;
01189   this->flags_ = msg_flags;
01190 }

ACE_INLINE char * ACE_Data_Block::base void    const
 

Get message data pointer.

Definition at line 54 of file Message_Block.i.

References ACE_TRACE, and base_.

Referenced by ACE_Message_Block::base.

00055 {
00056   ACE_TRACE ("ACE_Data_Block::base");
00057   return this->base_;
00058 }

ACE_INLINE size_t ACE_Data_Block::capacity void    const
 

Get the total amount of allocated space.

Definition at line 68 of file Message_Block.i.

References ACE_TRACE, and max_size_.

Referenced by ACE_Message_Block::capacity.

00069 {
00070   ACE_TRACE ("ACE_Data_Block::capacity");
00071   return this->max_size_;
00072 }

ACE_Data_Block * ACE_Data_Block::clone ACE_Message_Block::Message_Flags    mask = 0 const [virtual]
 

Return an exact "deep copy" of the message, i.e., create fresh new copies of all the Data_Blocks and continuations. Notice that Data_Blocks can act as "Prototypes", i.e. derived classes can override this method and create instances of themselves.

Definition at line 1040 of file Message_Block.cpp.

References ACE_TRACE, base_, clone_nocopy, ACE_OS_String::memcpy, and ACE_Message_Block::Message_Flags.

Referenced by ACE_Message_Block::clone, and ACE_InputCDR::steal_contents.

01041 {
01042   ACE_TRACE ("ACE_Data_Block::clone");
01043 
01044   ACE_Data_Block *nb = this->clone_nocopy (mask);
01045 
01046   // Copy all of the payload memory into the new object.
01047   if (nb != 0)
01048     {
01049       ACE_OS::memcpy (nb->base_,
01050                       this->base_,
01051                       this->max_size_);
01052     }
01053 
01054   return nb;
01055 }

ACE_Data_Block * ACE_Data_Block::clone_nocopy ACE_Message_Block::Message_Flags    mask = 0 const [virtual]
 

As clone above, but it does not copy the contents of the buffer, i.e., create a new Data_Block of the same dynamic type, with the same allocator, locking_strategy, and with the same amount of storage available but the buffer is unitialized.

Reimplemented in ACE_Locked_Data_Block.

Definition at line 1058 of file Message_Block.cpp.

References ACE_Data_Block, ACE_FUNCTION_TIMEPROBE, ACE_NEW_MALLOC_RETURN, ACE_TRACE, clr_flags, ACE_Message_Block::DONT_DELETE, and ACE_Message_Block::Message_Flags.

Referenced by ACE_InputCDR::ACE_InputCDR, ACE_Message_Block::ACE_Message_Block, clone, ACE_InputCDR::clone_from, and ACE_CDR::grow.

01059 {
01060   ACE_FUNCTION_TIMEPROBE(ACE_DATA_BLOCK_CLONE_ENTER);
01061 
01062   ACE_TRACE ("ACE_Data_Block::clone_nocopy");
01063 
01064   // You always want to clear this one to prevent memory leaks but you
01065   // might add some others later.
01066   const ACE_Message_Block::Message_Flags always_clear =
01067     ACE_Message_Block::DONT_DELETE;
01068 
01069   ACE_Data_Block *nb;
01070 
01071   ACE_NEW_MALLOC_RETURN (nb,
01072                          ACE_static_cast(ACE_Data_Block*,
01073                            this->data_block_allocator_->malloc (sizeof (ACE_Data_Block))),
01074                          ACE_Data_Block (this->max_size_, // size
01075                                          this->type_,     // type
01076                                          0,               // data
01077                                          this->allocator_strategy_, // allocator
01078                                          this->locking_strategy_, // locking strategy
01079                                          this->flags_,  // flags
01080                                          this->data_block_allocator_),
01081                          0);
01082 
01083 
01084   // Set new flags minus the mask...
01085   nb->clr_flags (mask | always_clear);
01086   return nb;
01087 }

ACE_INLINE ACE_Message_Block::Message_Flags ACE_Data_Block::clr_flags ACE_Message_Block::Message_Flags    less_flags
 

Clear the message flag bits specified in <less_flags> and return the new value.

Definition at line 84 of file Message_Block.i.

References ACE_CLR_BITS, ACE_TRACE, and ACE_Message_Block::Message_Flags.

Referenced by ACE_Locked_Data_Block::clone_nocopy, clone_nocopy, and ACE_Message_Block::clr_flags.

00085 {
00086   ACE_TRACE ("ACE_Data_Block::clr_flags");
00087   // Later we might mask more_flags so that user can't change internal
00088   // ones: less_flags &= ~(USER_FLAGS -1).
00089   return ACE_CLR_BITS (this->flags_, less_flags);
00090 }

ACE_INLINE ACE_Allocator * ACE_Data_Block::data_block_allocator void    const
 

Get the allocator used to create this object.

Definition at line 100 of file Message_Block.i.

References ACE_TRACE, and data_block_allocator_.

Referenced by ACE_Message_Block::ACE_Message_Block, ACE_Message_Block::clone, ACE_Locked_Data_Block::clone_nocopy, ACE_Message_Block::duplicate, ACE_OutputCDR::grow_and_adjust, ACE_Message_Block::release, and ACE_Message_Block::release_i.

00101 {
00102   ACE_TRACE ("ACE_Data_Block::data_block_allocator");
00103   return this->data_block_allocator_;
00104 }

void ACE_Data_Block::dump void    const
 

Dump the state of an object.

Definition at line 135 of file Message_Block.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, allocator_strategy_, ACE_Allocator::dump, and LM_DEBUG.

Referenced by ACE_Message_Block::dump.

00136 {
00137   ACE_TRACE ("ACE_Data_Block::dump");
00138   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00139   ACE_DEBUG ((LM_DEBUG,
00140               ACE_LIB_TEXT ("-----( Data Block )-----\n")
00141               ACE_LIB_TEXT ("type_ = %d\n")
00142               ACE_LIB_TEXT ("cur_size_ = %u\n")
00143               ACE_LIB_TEXT ("max_size_ = %u\n")
00144               ACE_LIB_TEXT ("flags_ = %u\n")
00145               ACE_LIB_TEXT ("base_ = %u\n")
00146               ACE_LIB_TEXT ("locking_strategy_ = %u\n")
00147               ACE_LIB_TEXT ("reference_count_ = %u\n")
00148               ACE_LIB_TEXT ("---------------------------\n"),
00149               this->type_,
00150               this->cur_size_,
00151               this->max_size_,
00152               this->flags_,
00153               this->base_,
00154               this->locking_strategy_,
00155               this->reference_count_));
00156   this->allocator_strategy_->dump ();
00157   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00158 }

ACE_Data_Block * ACE_Data_Block::duplicate void   
 

Return a "shallow" copy that increments our reference count by 1.

Definition at line 924 of file Message_Block.cpp.

References ACE_GUARD_RETURN, ACE_TRACE, locking_strategy_, and reference_count_.

Referenced by ACE_Message_Block::ACE_Message_Block, ACE_CDR::grow, ACE_InputCDR::operator=, ACE_InputCDR::steal_from, and ACE_OutputCDR::write_octet_array_mb.

00925 {
00926   ACE_TRACE ("ACE_Data_Block::duplicate");
00927 
00928   // Create a new <ACE_Message_Block>, but share the <base_> pointer
00929   // data (i.e., don't copy that).
00930   if (this->locking_strategy_)
00931     {
00932       // We need to acquire the lock before incrementing the count.
00933       ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->locking_strategy_, 0);
00934       this->reference_count_++;
00935     }
00936   else
00937     this->reference_count_++;
00938 
00939   return this;
00940 }

ACE_INLINE char * ACE_Data_Block::end void    const
 

Return a pointer to 1 past the end of the allocated data in a message.

Definition at line 335 of file Message_Block.i.

References ACE_TRACE, base_, and max_size_.

Referenced by ACE_Message_Block::end.

00336 {
00337   ACE_TRACE ("ACE_Data_Block::end");
00338   return this->base_ + this->max_size_;
00339 }

ACE_INLINE ACE_Message_Block::Message_Flags ACE_Data_Block::flags void    const
 

Get the current message flags.

Definition at line 93 of file Message_Block.i.

References ACE_TRACE, and flags_.

Referenced by ACE_Locked_Data_Block::clone_nocopy, and ACE_Message_Block::flags.

00094 {
00095   ACE_TRACE ("ACE_Data_Block::flags");
00096    return this->flags_;
00097 }

ACE_INLINE ACE_Lock * ACE_Data_Block::locking_strategy ACE_Lock  
 

Set a new locking strategy and return the hold one.

Definition at line 485 of file Message_Block.i.

References ACE_TRACE, and locking_strategy_.

00486 {
00487   ACE_TRACE ("ACE_Data_Block::locking_strategy");
00488   ACE_Lock *ols = this->locking_strategy_;
00489 
00490   this->locking_strategy_ = nls;
00491   return ols;
00492 }

ACE_INLINE ACE_Lock * ACE_Data_Block::locking_strategy void   
 

Get the locking strategy.

Definition at line 478 of file Message_Block.i.

References ACE_TRACE, and locking_strategy_.

Referenced by ACE_Message_Block::locking_strategy, and ACE_Message_Block::release.

00479 {
00480   ACE_TRACE ("ACE_Data_Block::locking_strategy");
00481   return this->locking_strategy_;
00482 }

ACE_INLINE char * ACE_Data_Block::mark void    const
 

Return a pointer to 1 past the end of the allotted data in a message. The allotted data may be less than allocated data if <size()> is passed an argument less than <capacity()>.

Definition at line 321 of file Message_Block.i.

References ACE_TRACE, base_, and cur_size_.

Referenced by ACE_Message_Block::mark.

00322 {
00323   ACE_TRACE ("ACE_Data_Block::mark");
00324   return this->base_ + this->cur_size_;
00325 }

ACE_INLINE void ACE_Data_Block::msg_type ACE_Message_Block::ACE_Message_Type    type
 

Set type of the message.

Definition at line 170 of file Message_Block.i.

References ACE_Message_Block::ACE_Message_Type, ACE_TRACE, and type_.

00171 {
00172   ACE_TRACE ("ACE_Data_Block::msg_type");
00173   this->type_ = t;
00174 }

ACE_INLINE ACE_Message_Block::ACE_Message_Type ACE_Data_Block::msg_type void    const
 

Get type of the message.

Definition at line 163 of file Message_Block.i.

References ACE_TRACE, and type_.

Referenced by ACE_Locked_Data_Block::clone_nocopy, and ACE_Message_Block::msg_type.

00164 {
00165   ACE_TRACE ("ACE_Data_Block::msg_type");
00166   return this->type_;
00167 }

ACE_Data_Block& ACE_Data_Block::operator= const ACE_Data_Block &    [private]
 

ACE_INLINE int ACE_Data_Block::reference_count void    const
 

Get the current reference count.

Definition at line 42 of file Message_Block.i.

References reference_count_.

Referenced by ACE_Message_Block::reference_count.

00043 {
00044   return reference_count_;
00045 }

ACE_Data_Block * ACE_Data_Block::release ACE_Lock   lock = 0
 

Decrease the shared reference count by 1. If the reference count is > 0 then return this; else if reference count == 0 then delete <this> and <mb> and return 0. Behavior is undefined if reference count < 0.

Definition at line 774 of file Message_Block.cpp.

References ACE_DES_FREE, ACE_TRACE, data_block_allocator_, ACE_Allocator::free, and release_no_delete.

Referenced by ACE_Message_Block::clone, ACE_Message_Block::data_block, ACE_Message_Block::init_i, and ACE_Message_Block::~ACE_Message_Block.

00775 {
00776   ACE_TRACE ("ACE_Data_Block::release");
00777 
00778   ACE_Allocator *allocator = this->data_block_allocator_;
00779 
00780   ACE_Data_Block *result = this->release_no_delete (lock);
00781 
00782   // We must delete this outside the scope of the locking_strategy_
00783   // since otherwise we'd be trying to "release" through a deleted
00784   // pointer!
00785   if (result == 0)
00786     ACE_DES_FREE (this,
00787                   allocator->free,
00788                   ACE_Data_Block);
00789   return result;
00790 }

ACE_Data_Block * ACE_Data_Block::release_i void    [protected]
 

Internal release implementation.

Definition at line 713 of file Message_Block.cpp.

References ACE_ASSERT, ACE_TRACE, and reference_count_.

Referenced by release_no_delete.

00714 {
00715   ACE_TRACE ("ACE_Data_Block::release_i");
00716 
00717   ACE_ASSERT (this->reference_count_ > 0);
00718 
00719   ACE_Data_Block *result = 0;
00720 
00721   // decrement reference count
00722   this->reference_count_--;
00723 
00724   if (this->reference_count_ == 0)
00725     // this will cause deletion of this
00726     result = 0;
00727   else
00728     result = this;
00729 
00730   return result;
00731 }

ACE_Data_Block * ACE_Data_Block::release_no_delete ACE_Lock   lock [protected]
 

Definition at line 734 of file Message_Block.cpp.

References ACE_GUARD_RETURN, ACE_TRACE, locking_strategy_, and release_i.

Referenced by release, and ACE_Message_Block::release_i.

00735 {
00736   ACE_TRACE ("ACE_Data_Block::release_no_delete");
00737 
00738   ACE_Data_Block *result = 0;
00739   ACE_Lock *lock_to_be_used = 0;
00740 
00741   // Check if we were passed in a lock
00742   if (lock != 0)
00743     {
00744       // Make sure that the lock passed in and our lock are the same
00745       if (lock == this->locking_strategy_)
00746         // In this case no locking is required.
00747         lock_to_be_used = 0;
00748 
00749       // The lock passed in does not match our lock
00750       else
00751         // Lock to be used is our lock
00752         lock_to_be_used = this->locking_strategy_;
00753     }
00754   // This is the case when no lock was passed in
00755   else
00756     // Lock to be used is our lock
00757     lock_to_be_used = this->locking_strategy_;
00758 
00759   // If there's a locking strategy then we need to acquire the lock
00760   // before decrementing the count.
00761   if (lock_to_be_used != 0)
00762     {
00763       ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock_to_be_used, 0);
00764 
00765       result = this->release_i ();
00766     }
00767   else
00768     result = this->release_i ();
00769 
00770   return result;
00771 }

ACE_INLINE ACE_Message_Block::Message_Flags ACE_Data_Block::set_flags ACE_Message_Block::Message_Flags    more_flags
 

Bitwise-or the <more_flags> into the existing message flags and return the new value.

Definition at line 75 of file Message_Block.i.

References ACE_SET_BITS, ACE_TRACE, and ACE_Message_Block::Message_Flags.

Referenced by ACE_Message_Block::set_flags.

00076 {
00077   ACE_TRACE ("ACE_Data_Block::set_flags");
00078   // Later we might mask more_glags so that user can't change internal
00079   // ones: more_flags &= ~(USER_FLAGS -1).
00080   return ACE_SET_BITS (this->flags_, more_flags);
00081 }

int ACE_Data_Block::size size_t    length
 

Set the total amount of space in the message. Returns 0 if successful, else -1.

Definition at line 185 of file Message_Block.cpp.

References ACE_ALLOCATOR_RETURN, ACE_BIT_DISABLED, ACE_CLR_BITS, ACE_TRACE, allocator_strategy_, base_, cur_size_, ACE_Message_Block::DONT_DELETE, ACE_Allocator::free, max_size_, and ACE_OS_String::memcpy.

00186 {
00187   ACE_TRACE ("ACE_Data_Block::size");
00188 
00189   if (length <= this->max_size_)
00190     this->cur_size_ = length;
00191   else
00192     {
00193       // We need to resize!
00194       char *buf;
00195       ACE_ALLOCATOR_RETURN (buf,
00196                             (char *) this->allocator_strategy_->malloc (length),
00197                             -1);
00198 
00199       ACE_OS::memcpy (buf,
00200                       this->base_,
00201                       this->cur_size_);
00202       if (ACE_BIT_DISABLED (this->flags_,
00203                             ACE_Message_Block::DONT_DELETE))
00204         this->allocator_strategy_->free ((void *) this->base_);
00205       else
00206         // We now assume ownership.
00207         ACE_CLR_BITS (this->flags_,
00208                       ACE_Message_Block::DONT_DELETE);
00209       this->max_size_ = length;
00210       this->cur_size_ = length;
00211       this->base_ = buf;
00212     }
00213   return 0;
00214 }

ACE_INLINE size_t ACE_Data_Block::size void    const
 

Get the total amount of allotted space in the message. The amount of allotted space may be less than allocated space.

Definition at line 61 of file Message_Block.i.

References ACE_TRACE, and cur_size_.

Referenced by ACE_Data_Block, ACE_Locked_Data_Block::clone_nocopy, ACE_CDR::grow, ACE_Message_Block::init_i, and ACE_Message_Block::size.

00062 {
00063   ACE_TRACE ("ACE_Data_Block::size");
00064   return this->cur_size_;
00065 }


Friends And Related Function Documentation

friend class ACE_Message_Block [friend]
 

Decrease the reference count, but don't delete the object. Returns 0 if the object should be removed. If <lock> is equal to the locking strategy then we assume that the lock is beign held by the current thread; this is used to release all the data blocks in a chain while holding a single lock.

Definition at line 797 of file Message_Block.h.


Member Data Documentation

ACE_Allocator* ACE_Data_Block::allocator_strategy_ [protected]
 

Pointer to the allocator defined for this <ACE_Data_Block>. Note that this pointer is shared by all owners of this <ACE_Data_Block>.

Definition at line 821 of file Message_Block.h.

Referenced by ACE_Message_Block::access_allocators, ACE_Data_Block, allocator_strategy, base, dump, ACE_Message_Block::reset_allocators, size, and ~ACE_Data_Block.

char* ACE_Data_Block::base_ [protected]
 

Pointer To beginning of message payload.

Definition at line 813 of file Message_Block.h.

Referenced by base, clone, end, mark, size, and ~ACE_Data_Block.

size_t ACE_Data_Block::cur_size_ [protected]
 

Current size of message block.

Definition at line 804 of file Message_Block.h.

Referenced by ACE_Data_Block, base, mark, and size.

ACE_Allocator* ACE_Data_Block::data_block_allocator_ [protected]
 

The allocator use to destroy ourselves.

Definition at line 840 of file Message_Block.h.

Referenced by ACE_Message_Block::access_allocators, ACE_Data_Block, data_block_allocator, release, and ACE_Message_Block::reset_allocators.

ACE_Message_Block::Message_Flags ACE_Data_Block::flags_ [protected]
 

Misc flags (e.g., DONT_DELETE and USER_FLAGS).

Definition at line 810 of file Message_Block.h.

Referenced by base, and flags.

ACE_Lock* ACE_Data_Block::locking_strategy_ [protected]
 

Pointer to the locking strategy defined for this <ACE_Data_Block>. This is used to protect regions of code that access shared <ACE_Data_Block> state. Note that this lock is shared by all owners of the <ACE_Data_Block>'s data.

Definition at line 829 of file Message_Block.h.

Referenced by ACE_Locked_Data_Block::ACE_Locked_Data_Block, duplicate, locking_strategy, and release_no_delete.

size_t ACE_Data_Block::max_size_ [protected]
 

Total size of buffer.

Definition at line 807 of file Message_Block.h.

Referenced by ACE_Data_Block, base, capacity, end, and size.

int ACE_Data_Block::reference_count_ [protected]
 

Reference count for this <ACE_Data_Block>, which is used to avoid deep copies (i.e., <clone>). Note that this pointer value is shared by all owners of the <Data_Block>'s data, i.e., all the <ACE_Message_Block>s.

Definition at line 837 of file Message_Block.h.

Referenced by duplicate, reference_count, release_i, and ~ACE_Data_Block.

ACE_Message_Block::ACE_Message_Type ACE_Data_Block::type_ [protected]
 

Type of message.

Definition at line 801 of file Message_Block.h.

Referenced by msg_type.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:47:01 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002