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 Member Functions

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

 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.

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

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

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

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

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).

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

char * mark (void) const
size_t size (void) const
int size (size_t length)
size_t capacity (void) const
 Get the total amount of allocated space.

virtual ACE_Data_Blockclone (ACE_Message_Block::Message_Flags mask=0) const
virtual ACE_Data_Blockclone_nocopy (ACE_Message_Block::Message_Flags mask=0) const
ACE_Data_Blockduplicate (void)
 Return a "shallow" copy that increments our reference count by 1.

ACE_Data_Blockrelease (ACE_Lock *lock=0)
ACE_Message_Block::Message_Flags set_flags (ACE_Message_Block::Message_Flags more_flags)
ACE_Message_Block::Message_Flags clr_flags (ACE_Message_Block::Message_Flags less_flags)
ACE_Message_Block::Message_Flags flags (void) const
 Get the current message flags.

ACE_Allocatorallocator_strategy (void) const
 Obtain the allocator strategy.

ACE_Locklocking_strategy (void)
 Get the locking strategy.

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

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

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

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


Protected Member Functions

virtual ACE_Data_Blockrelease_i (void)
 Internal release implementation.

int reference_count_i (void) const
 Internal get the current reference count.

ACE_Data_Blockrelease_no_delete (ACE_Lock *lock)

Protected Attributes

ACE_Message_Block::ACE_Message_Type type_
 Type of message.

size_t cur_size_
 Current size of message block.

size_t max_size_
 Total size of buffer.

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

char * base_
 Pointer To beginning of message payload.

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


Private Member Functions

ACE_Data_Blockoperator= (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 (which protects the reference count from race conditions in concurrent programs) and the (which determines what memory pool is used to allocate the memory).

Definition at line 677 of file Message_Block.h.


Constructor & Destructor Documentation

ACE_Data_Block::ACE_Data_Block void   ) 
 

Default "do-nothing" constructor.

Definition at line 309 of file Message_Block.cpp.

References ACE_ALLOCATOR, ACE_FUNCTION_TIMEPROBE, and ACE_TRACE.

Referenced by clone_nocopy().

00310   : type_ (ACE_Message_Block::MB_DATA),
00311     cur_size_ (0),
00312     max_size_ (0),
00313     flags_ (ACE_Message_Block::DONT_DELETE),
00314     base_ (0),
00315     allocator_strategy_ (0),
00316     locking_strategy_ (0),
00317     reference_count_ (1),
00318     data_block_allocator_ (0)
00319 {
00320   ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
00321   ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR1_ENTER);
00322 
00323   ACE_ALLOCATOR (this->allocator_strategy_,
00324                  ACE_Allocator::instance ());
00325 
00326   ACE_ALLOCATOR (this->data_block_allocator_,
00327                  ACE_Allocator::instance ());
00328 }

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 330 of file Message_Block.cpp.

References ACE_ALLOCATOR, ACE_FUNCTION_TIMEPROBE, ACE_Message_Block::ACE_Message_Type, ACE_TRACE, allocator_strategy_, and ACE_Message_Block::Message_Flags.

00337   : type_ (msg_type),
00338     cur_size_ (0),          // Reset later if memory alloc'd ok
00339     max_size_ (0),
00340     flags_ (flags),
00341     base_ (const_cast <char *> (msg_data)),
00342     allocator_strategy_ (allocator_strategy),
00343     locking_strategy_ (locking_strategy),
00344     reference_count_ (1),
00345     data_block_allocator_ (data_block_allocator)
00346 {
00347   ACE_TRACE ("ACE_Data_Block::ACE_Data_Block");
00348   ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR2_ENTER);
00349 
00350   // If the user didn't pass one in, let's use the
00351   // <ACE_Allocator::instance>.
00352   if (this->allocator_strategy_ == 0)
00353     ACE_ALLOCATOR (this->allocator_strategy_,
00354                    ACE_Allocator::instance ());
00355 
00356   if (this->data_block_allocator_ == 0)
00357     ACE_ALLOCATOR (this->data_block_allocator_,
00358                    ACE_Allocator::instance ());
00359 
00360   if (msg_data == 0)
00361     ACE_ALLOCATOR (this->base_,
00362                    (char *) this->allocator_strategy_->malloc (size));
00363     // ACE_ALLOCATOR returns on alloc failure...
00364 
00365   // The memory is legit, whether passed in or allocated, so set the size.
00366   this->cur_size_ = this->max_size_ = size;
00367 }

ACE_Data_Block::~ACE_Data_Block void   )  [virtual]
 

Delete all the resources held in the message.

Definition at line 730 of file Message_Block.cpp.

References ACE_ASSERT, ACE_BIT_DISABLED, allocator_strategy_, and ACE_Allocator::free().

00731 {
00732   // Sanity check...
00733   ACE_ASSERT (this->reference_count_ <= 1);
00734 
00735   // Just to be safe...
00736   this->reference_count_ = 0;
00737 
00738   if (ACE_BIT_DISABLED (this->flags_,
00739                         ACE_Message_Block::DONT_DELETE))
00740     {
00741       this->allocator_strategy_->free ((void *) this->base_);
00742       this->base_ = 0;
00743     }
00744 }

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 469 of file Message_Block.inl.

References ACE_TRACE, and allocator_strategy_.

Referenced by ACE_Locked_Data_Block< ACE_LOCK >::clone_nocopy().

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

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 1216 of file Message_Block.cpp.

References ACE_BIT_DISABLED, allocator_strategy_, ACE_Allocator::free(), and ACE_Message_Block::Message_Flags.

01219 {
01220   if (ACE_BIT_DISABLED (this->flags_,
01221                         ACE_Message_Block::DONT_DELETE))
01222     this->allocator_strategy_->free (this->base_);
01223 
01224   this->max_size_ = msg_length;
01225   this->cur_size_ = msg_length;
01226   this->base_ = msg_data;
01227   this->flags_ = msg_flags;
01228 }

ACE_INLINE char * ACE_Data_Block::base void   )  const
 

Get message data pointer.

Definition at line 52 of file Message_Block.inl.

References ACE_TRACE.

Referenced by ACE_Message_Block::base().

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

ACE_INLINE size_t ACE_Data_Block::capacity void   )  const
 

Get the total amount of allocated space.

Definition at line 66 of file Message_Block.inl.

References ACE_TRACE.

Referenced by ACE_Message_Block::capacity().

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

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 1074 of file Message_Block.cpp.

References ACE_TRACE, base_, clone_nocopy(), ACE_OS::memcpy(), and ACE_Message_Block::Message_Flags.

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

01075 {
01076   ACE_TRACE ("ACE_Data_Block::clone");
01077 
01078   ACE_Data_Block *nb = this->clone_nocopy (mask);
01079 
01080   // Copy all of the payload memory into the new object. The new block
01081   // was allocated with max_size_ (and, thus, it's cur_size_ is the same
01082   // as max_size_). Maintain the same "has been written" boundary in the
01083   // new block by only copying cur_size_ bytes.
01084   if (nb != 0)
01085     {
01086       ACE_OS::memcpy (nb->base_,
01087                       this->base_,
01088                       this->cur_size_);
01089     }
01090 
01091   return nb;
01092 }

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< ACE_LOCK >.

Definition at line 1095 of file Message_Block.cpp.

References ACE_Data_Block(), ACE_FUNCTION_TIMEPROBE, ACE_NEW_MALLOC_RETURN, ACE_TRACE, clr_flags(), 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().

01096 {
01097   ACE_FUNCTION_TIMEPROBE(ACE_DATA_BLOCK_CLONE_ENTER);
01098 
01099   ACE_TRACE ("ACE_Data_Block::clone_nocopy");
01100 
01101   // You always want to clear this one to prevent memory leaks but you
01102   // might add some others later.
01103   const ACE_Message_Block::Message_Flags always_clear =
01104     ACE_Message_Block::DONT_DELETE;
01105 
01106   ACE_Data_Block *nb = 0;
01107 
01108   ACE_NEW_MALLOC_RETURN (nb,
01109                          static_cast<ACE_Data_Block*> (
01110                            this->data_block_allocator_->malloc (sizeof (ACE_Data_Block))),
01111                          ACE_Data_Block (this->max_size_, // size
01112                                          this->type_,     // type
01113                                          0,               // data
01114                                          this->allocator_strategy_, // allocator
01115                                          this->locking_strategy_, // locking strategy
01116                                          this->flags_,  // flags
01117                                          this->data_block_allocator_),
01118                          0);
01119 
01120 
01121   // Set new flags minus the mask...
01122   nb->clr_flags (mask | always_clear);
01123   return nb;
01124 }

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 and return the new value.

Definition at line 82 of file Message_Block.inl.

References ACE_CLR_BITS, ACE_TRACE, and ACE_Message_Block::Message_Flags.

Referenced by ACE_Locked_Data_Block< ACE_LOCK >::clone_nocopy(), clone_nocopy(), and ACE_Message_Block::clr_flags().

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

ACE_INLINE ACE_Allocator * ACE_Data_Block::data_block_allocator void   )  const
 

Get the allocator used to create this object.

Definition at line 98 of file Message_Block.inl.

References ACE_TRACE.

Referenced by ACE_Message_Block::ACE_Message_Block(), ACE_Message_Block::clone(), ACE_Locked_Data_Block< ACE_LOCK >::clone_nocopy(), ACE_Message_Block::duplicate(), ACE_OutputCDR::grow_and_adjust(), ACE_Message_Block::release(), and ACE_Message_Block::release_i().

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

void ACE_Data_Block::dump void   )  const
 

Dump the state of an object.

Definition at line 140 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().

00141 {
00142 #if defined (ACE_HAS_DUMP)
00143   ACE_TRACE ("ACE_Data_Block::dump");
00144   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00145   ACE_DEBUG ((LM_DEBUG,
00146               ACE_LIB_TEXT ("-----( Data Block )-----\n")
00147               ACE_LIB_TEXT ("type_ = %d\n")
00148               ACE_LIB_TEXT ("cur_size_ = %u\n")
00149               ACE_LIB_TEXT ("max_size_ = %u\n")
00150               ACE_LIB_TEXT ("flags_ = %u\n")
00151               ACE_LIB_TEXT ("base_ = %u\n")
00152               ACE_LIB_TEXT ("locking_strategy_ = %u\n")
00153               ACE_LIB_TEXT ("reference_count_ = %u\n")
00154               ACE_LIB_TEXT ("---------------------------\n"),
00155               this->type_,
00156               this->cur_size_,
00157               this->max_size_,
00158               this->flags_,
00159               this->base_,
00160               this->locking_strategy_,
00161               this->reference_count_));
00162   this->allocator_strategy_->dump ();
00163   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00164 #endif /* ACE_HAS_DUMP */
00165 }

ACE_Data_Block * ACE_Data_Block::duplicate void   ) 
 

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

Definition at line 958 of file Message_Block.cpp.

References ACE_GUARD_RETURN, ACE_TRACE, and locking_strategy_.

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().

00959 {
00960   ACE_TRACE ("ACE_Data_Block::duplicate");
00961 
00962   // Create a new <ACE_Message_Block>, but share the <base_> pointer
00963   // data (i.e., don't copy that).
00964   if (this->locking_strategy_)
00965     {
00966       // We need to acquire the lock before incrementing the count.
00967       ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->locking_strategy_, 0);
00968       ++this->reference_count_;
00969     }
00970   else
00971     ++this->reference_count_;
00972 
00973   return this;
00974 }

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 333 of file Message_Block.inl.

References ACE_TRACE.

Referenced by ACE_Message_Block::end().

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

ACE_INLINE ACE_Message_Block::Message_Flags ACE_Data_Block::flags void   )  const
 

Get the current message flags.

Definition at line 91 of file Message_Block.inl.

References ACE_TRACE.

Referenced by ACE_Locked_Data_Block< ACE_LOCK >::clone_nocopy(), and ACE_Message_Block::flags().

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

ACE_INLINE ACE_Lock * ACE_Data_Block::locking_strategy ACE_Lock  ) 
 

Set a new locking strategy and return the hold one.

Definition at line 483 of file Message_Block.inl.

References ACE_TRACE, and locking_strategy_.

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

ACE_INLINE ACE_Lock * ACE_Data_Block::locking_strategy void   ) 
 

Get the locking strategy.

Definition at line 476 of file Message_Block.inl.

References ACE_TRACE, and locking_strategy_.

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

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

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 319 of file Message_Block.inl.

References ACE_TRACE.

Referenced by ACE_Message_Block::mark().

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

ACE_INLINE void ACE_Data_Block::msg_type ACE_Message_Block::ACE_Message_Type  type  ) 
 

Set type of the message.

Definition at line 168 of file Message_Block.inl.

References ACE_Message_Block::ACE_Message_Type, and ACE_TRACE.

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

ACE_INLINE ACE_Message_Block::ACE_Message_Type ACE_Data_Block::msg_type void   )  const
 

Get type of the message.

Definition at line 161 of file Message_Block.inl.

References ACE_TRACE.

Referenced by ACE_Locked_Data_Block< ACE_LOCK >::clone_nocopy(), and ACE_Message_Block::msg_type().

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

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

int ACE_Data_Block::reference_count void   )  const
 

Get the current reference count.

Definition at line 194 of file Message_Block.cpp.

References ACE_GUARD_RETURN, locking_strategy_, and reference_count_i().

Referenced by ACE_Message_Block::reference_count().

00195 {
00196   if (this->locking_strategy_)
00197     {
00198       // We need to acquire the lock before retrieving the count
00199       ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->locking_strategy_, 0);
00200 
00201       return this->reference_count_i ();
00202     }
00203 
00204   return this->reference_count_i ();
00205 }

ACE_INLINE int ACE_Data_Block::reference_count_i void   )  const [protected]
 

Internal get the current reference count.

Definition at line 40 of file Message_Block.inl.

Referenced by reference_count().

00041 {
00042   return reference_count_;
00043 }

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 and and return 0. Behavior is undefined if reference count < 0.

Definition at line 808 of file Message_Block.cpp.

References ACE_DES_FREE, ACE_TRACE, 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().

00809 {
00810   ACE_TRACE ("ACE_Data_Block::release");
00811 
00812   ACE_Allocator *allocator = this->data_block_allocator_;
00813 
00814   ACE_Data_Block *result = this->release_no_delete (lock);
00815 
00816   // We must delete this outside the scope of the locking_strategy_
00817   // since otherwise we'd be trying to "release" through a deleted
00818   // pointer!
00819   if (result == 0)
00820     ACE_DES_FREE (this,
00821                   allocator->free,
00822                   ACE_Data_Block);
00823   return result;
00824 }

ACE_Data_Block * ACE_Data_Block::release_i void   )  [protected, virtual]
 

Internal release implementation.

Definition at line 747 of file Message_Block.cpp.

References ACE_ASSERT, and ACE_TRACE.

Referenced by release_no_delete().

00748 {
00749   ACE_TRACE ("ACE_Data_Block::release_i");
00750 
00751   ACE_ASSERT (this->reference_count_ > 0);
00752 
00753   ACE_Data_Block *result = 0;
00754 
00755   // decrement reference count
00756   --this->reference_count_;
00757 
00758   if (this->reference_count_ == 0)
00759     // this will cause deletion of this
00760     result = 0;
00761   else
00762     result = this;
00763 
00764   return result;
00765 }

ACE_Data_Block * ACE_Data_Block::release_no_delete ACE_Lock lock  )  [protected]
 

Definition at line 768 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().

00769 {
00770   ACE_TRACE ("ACE_Data_Block::release_no_delete");
00771 
00772   ACE_Data_Block *result = 0;
00773   ACE_Lock *lock_to_be_used = 0;
00774 
00775   // Check if we were passed in a lock
00776   if (lock != 0)
00777     {
00778       // Make sure that the lock passed in and our lock are the same
00779       if (lock == this->locking_strategy_)
00780         // In this case no locking is required.
00781         lock_to_be_used = 0;
00782 
00783       // The lock passed in does not match our lock
00784       else
00785         // Lock to be used is our lock
00786         lock_to_be_used = this->locking_strategy_;
00787     }
00788   // This is the case when no lock was passed in
00789   else
00790     // Lock to be used is our lock
00791     lock_to_be_used = this->locking_strategy_;
00792 
00793   // If there's a locking strategy then we need to acquire the lock
00794   // before decrementing the count.
00795   if (lock_to_be_used != 0)
00796     {
00797       ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock_to_be_used, 0);
00798 
00799       result = this->release_i ();
00800     }
00801   else
00802     result = this->release_i ();
00803 
00804   return result;
00805 }

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

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

Definition at line 73 of file Message_Block.inl.

References ACE_SET_BITS, ACE_TRACE, and ACE_Message_Block::Message_Flags.

Referenced by ACE_Message_Block::set_flags().

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

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 208 of file Message_Block.cpp.

References ACE_ALLOCATOR_RETURN, ACE_BIT_DISABLED, ACE_CLR_BITS, ACE_TRACE, allocator_strategy_, ACE_Allocator::free(), and ACE_OS::memcpy().

00209 {
00210   ACE_TRACE ("ACE_Data_Block::size");
00211 
00212   if (length <= this->max_size_)
00213     this->cur_size_ = length;
00214   else
00215     {
00216       // We need to resize!
00217       char *buf = 0;
00218       ACE_ALLOCATOR_RETURN (buf,
00219                             (char *) this->allocator_strategy_->malloc (length),
00220                             -1);
00221 
00222       ACE_OS::memcpy (buf,
00223                       this->base_,
00224                       this->cur_size_);
00225       if (ACE_BIT_DISABLED (this->flags_,
00226                             ACE_Message_Block::DONT_DELETE))
00227         this->allocator_strategy_->free ((void *) this->base_);
00228       else
00229         // We now assume ownership.
00230         ACE_CLR_BITS (this->flags_,
00231                       ACE_Message_Block::DONT_DELETE);
00232       this->max_size_ = length;
00233       this->cur_size_ = length;
00234       this->base_ = buf;
00235     }
00236   return 0;
00237 }

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 59 of file Message_Block.inl.

References ACE_TRACE.

Referenced by ACE_InputCDR::clone_from(), ACE_Locked_Data_Block< ACE_LOCK >::clone_nocopy(), ACE_CDR::grow(), ACE_Message_Block::init_i(), and ACE_Message_Block::size().

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


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 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 807 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 831 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 823 of file Message_Block.h.

Referenced by clone().

size_t ACE_Data_Block::cur_size_ [protected]
 

Current size of message block.

Definition at line 814 of file Message_Block.h.

ACE_Allocator* ACE_Data_Block::data_block_allocator_ [protected]
 

The allocator use to destroy ourselves.

Definition at line 850 of file Message_Block.h.

Referenced by ACE_Message_Block::access_allocators(), 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 820 of file Message_Block.h.

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 839 of file Message_Block.h.

Referenced by duplicate(), locking_strategy(), reference_count(), and release_no_delete().

size_t ACE_Data_Block::max_size_ [protected]
 

Total size of buffer.

Definition at line 817 of file Message_Block.h.

int ACE_Data_Block::reference_count_ [protected]
 

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

Definition at line 847 of file Message_Block.h.

ACE_Message_Block::ACE_Message_Type ACE_Data_Block::type_ [protected]
 

Type of message.

Definition at line 811 of file Message_Block.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:21:15 2006 for ACE by doxygen 1.3.6