#include <Message_Block.h>
Inheritance diagram for ACE_Data_Block:
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_Block * | clone (ACE_Message_Block::Message_Flags mask=0) const |
virtual ACE_Data_Block * | clone_nocopy (ACE_Message_Block::Message_Flags mask=0, size_t max_size=0) const |
ACE_Data_Block * | duplicate (void) |
Return a "shallow" copy that increments our reference count by 1. | |
ACE_Data_Block * | release (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_Allocator * | allocator_strategy (void) const |
Obtain the allocator strategy. | |
ACE_Lock * | locking_strategy (void) |
Get the locking strategy. | |
ACE_Lock * | locking_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_Allocator * | data_block_allocator (void) const |
Get the allocator used to create this object. | |
Protected Member Functions | |
virtual ACE_Data_Block * | release_i (void) |
Internal release implementation. | |
int | reference_count_i (void) const |
Internal get the current reference count. | |
ACE_Data_Block * | release_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_Allocator * | allocator_strategy_ |
ACE_Lock * | locking_strategy_ |
int | reference_count_ |
ACE_Allocator * | data_block_allocator_ |
The allocator use to destroy ourselves. | |
Private Member Functions | |
ACE_Data_Block & | operator= (const ACE_Data_Block &) |
ACE_Data_Block (const ACE_Data_Block &) | |
Friends | |
class | ACE_Message_Block |
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 677 of file Message_Block.h.
ACE_Data_Block::ACE_Data_Block | ( | void | ) |
Default "do-nothing" constructor.
Definition at line 315 of file Message_Block.cpp.
References ACE_ALLOCATOR, ACE_FUNCTION_TIMEPROBE, ACE_TRACE, and ACE_Allocator::instance().
00316 : type_ (ACE_Message_Block::MB_DATA), 00317 cur_size_ (0), 00318 max_size_ (0), 00319 flags_ (ACE_Message_Block::DONT_DELETE), 00320 base_ (0), 00321 allocator_strategy_ (0), 00322 locking_strategy_ (0), 00323 reference_count_ (1), 00324 data_block_allocator_ (0) 00325 { 00326 ACE_TRACE ("ACE_Data_Block::ACE_Data_Block"); 00327 ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR1_ENTER); 00328 00329 ACE_ALLOCATOR (this->allocator_strategy_, 00330 ACE_Allocator::instance ()); 00331 00332 ACE_ALLOCATOR (this->data_block_allocator_, 00333 ACE_Allocator::instance ()); 00334 }
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 336 of file Message_Block.cpp.
References ACE_ALLOCATOR, ACE_FUNCTION_TIMEPROBE, ACE_TRACE, cur_size_, ACE_Allocator::instance(), max_size_, and ACE_OS::memset().
00343 : type_ (msg_type), 00344 cur_size_ (0), // Reset later if memory alloc'd ok 00345 max_size_ (0), 00346 flags_ (flags), 00347 base_ (const_cast <char *> (msg_data)), 00348 allocator_strategy_ (allocator_strategy), 00349 locking_strategy_ (locking_strategy), 00350 reference_count_ (1), 00351 data_block_allocator_ (data_block_allocator) 00352 { 00353 ACE_TRACE ("ACE_Data_Block::ACE_Data_Block"); 00354 ACE_FUNCTION_TIMEPROBE (ACE_DATA_BLOCK_CTOR2_ENTER); 00355 00356 // If the user didn't pass one in, let's use the 00357 // <ACE_Allocator::instance>. 00358 if (this->allocator_strategy_ == 0) 00359 ACE_ALLOCATOR (this->allocator_strategy_, 00360 ACE_Allocator::instance ()); 00361 00362 if (this->data_block_allocator_ == 0) 00363 ACE_ALLOCATOR (this->data_block_allocator_, 00364 ACE_Allocator::instance ()); 00365 00366 if (msg_data == 0) 00367 { 00368 ACE_ALLOCATOR (this->base_, 00369 (char *) this->allocator_strategy_->malloc (size)); 00370 #if defined (ACE_INITIALIZE_MEMORY_BEFORE_USE) 00371 (void) ACE_OS::memset (this->base_, 00372 '\0', 00373 size); 00374 #endif /* ACE_INITIALIZE_MEMORY_BEFORE_USE */ 00375 } 00376 00377 // ACE_ALLOCATOR returns on alloc failure but we cant throw, so setting 00378 // the size to 0 (i.e. "bad bit") ... 00379 if (this->base_ == 0) 00380 { 00381 size = 0; 00382 } 00383 00384 // The memory is legit, whether passed in or allocated, so set 00385 // the size. 00386 this->cur_size_ = this->max_size_ = size; 00387 }
ACE_Data_Block::~ACE_Data_Block | ( | void | ) | [virtual] |
Delete all the resources held in the message.
Definition at line 758 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_.
00759 { 00760 // Sanity check... 00761 ACE_ASSERT (this->reference_count_ <= 1); 00762 00763 // Just to be safe... 00764 this->reference_count_ = 0; 00765 00766 if (ACE_BIT_DISABLED (this->flags_, 00767 ACE_Message_Block::DONT_DELETE)) 00768 { 00769 this->allocator_strategy_->free ((void *) this->base_); 00770 this->base_ = 0; 00771 } 00772 }
ACE_Data_Block::ACE_Data_Block | ( | const ACE_Data_Block & | ) | [private] |
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 1259 of file Message_Block.cpp.
References ACE_BIT_DISABLED, allocator_strategy_, base_, cur_size_, ACE_Message_Block::DONT_DELETE, flags_, ACE_Allocator::free(), and max_size_.
01262 { 01263 if (ACE_BIT_DISABLED (this->flags_, 01264 ACE_Message_Block::DONT_DELETE)) 01265 this->allocator_strategy_->free (this->base_); 01266 01267 this->max_size_ = msg_length; 01268 this->cur_size_ = msg_length; 01269 this->base_ = msg_data; 01270 this->flags_ = msg_flags; 01271 }
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, and base_.
Referenced by ACE_Message_Block::base(), and ACE_CDR::grow().
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, and max_size_.
Referenced by ACE_Message_Block::capacity().
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 1102 of file Message_Block.cpp.
References ACE_TRACE, base_, clone_nocopy(), and ACE_OS::memcpy().
Referenced by ACE_Message_Block::clone(), and ACE_InputCDR::steal_contents().
01103 { 01104 ACE_TRACE ("ACE_Data_Block::clone"); 01105 01106 ACE_Data_Block *nb = this->clone_nocopy (mask); 01107 01108 // Copy all of the payload memory into the new object. The new block 01109 // was allocated with max_size_ (and, thus, it's cur_size_ is the same 01110 // as max_size_). Maintain the same "has been written" boundary in the 01111 // new block by only copying cur_size_ bytes. 01112 if (nb != 0) 01113 { 01114 ACE_OS::memcpy (nb->base_, 01115 this->base_, 01116 this->cur_size_); 01117 } 01118 01119 return nb; 01120 }
ACE_Data_Block * ACE_Data_Block::clone_nocopy | ( | ACE_Message_Block::Message_Flags | mask = 0 , |
|
size_t | max_size = 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 (if max_size is zero) but the buffer is unitialized. If max_size is specified other than zero, it will be used when creating the new data block.
Reimplemented in ACE_Locked_Data_Block< ACE_LOCK >.
Definition at line 1123 of file Message_Block.cpp.
References ACE_FUNCTION_TIMEPROBE, ACE_NEW_MALLOC_RETURN, ACE_TRACE, clr_flags(), data_block_allocator_, ACE_Message_Block::DONT_DELETE, ACE_Allocator::free(), max_size_, and size().
Referenced by ACE_InputCDR::ACE_InputCDR(), ACE_Message_Block::ACE_Message_Block(), clone(), ACE_InputCDR::clone_from(), and ACE_CDR::grow().
01125 { 01126 ACE_FUNCTION_TIMEPROBE(ACE_DATA_BLOCK_CLONE_ENTER); 01127 01128 ACE_TRACE ("ACE_Data_Block::clone_nocopy"); 01129 01130 // You always want to clear this one to prevent memory leaks but you 01131 // might add some others later. 01132 const ACE_Message_Block::Message_Flags always_clear = 01133 ACE_Message_Block::DONT_DELETE; 01134 01135 const size_t newsize = 01136 max_size == 0 ? this->max_size_ : max_size; 01137 01138 ACE_Data_Block *nb = 0; 01139 01140 ACE_NEW_MALLOC_RETURN (nb, 01141 static_cast<ACE_Data_Block*> ( 01142 this->data_block_allocator_->malloc (sizeof (ACE_Data_Block))), 01143 ACE_Data_Block (newsize, // size 01144 this->type_, // type 01145 0, // data 01146 this->allocator_strategy_, // allocator 01147 this->locking_strategy_, // locking strategy 01148 this->flags_, // flags 01149 this->data_block_allocator_), 01150 0); 01151 01152 // Message block initialization may fail while the construction 01153 // succeds. Since as a matter of policy, ACE may throw no 01154 // exceptions, we have to do a separate check like this. 01155 if (nb != 0 && nb->size () < newsize) 01156 { 01157 nb->ACE_Data_Block::~ACE_Data_Block(); // placement destructor ... 01158 this->data_block_allocator_->free (nb); // free ... 01159 errno = ENOMEM; 01160 return 0; 01161 } 01162 01163 01164 // Set new flags minus the mask... 01165 nb->clr_flags (mask | always_clear); 01166 return nb; 01167 }
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 82 of file Message_Block.inl.
References ACE_CLR_BITS, and ACE_TRACE.
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, and data_block_allocator_.
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 146 of file Message_Block.cpp.
References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, ACE_TRACE, allocator_strategy_, ACE_Allocator::dump(), and LM_DEBUG.
Referenced by ACE_Message_Block::dump().
00147 { 00148 #if defined (ACE_HAS_DUMP) 00149 ACE_TRACE ("ACE_Data_Block::dump"); 00150 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00151 ACE_DEBUG ((LM_DEBUG, 00152 ACE_TEXT ("-----( Data Block )-----\n") 00153 ACE_TEXT ("type_ = %d\n") 00154 ACE_TEXT ("cur_size_ = %u\n") 00155 ACE_TEXT ("max_size_ = %u\n") 00156 ACE_TEXT ("flags_ = %u\n") 00157 ACE_TEXT ("base_ = %u\n") 00158 ACE_TEXT ("locking_strategy_ = %u\n") 00159 ACE_TEXT ("reference_count_ = %u\n") 00160 ACE_TEXT ("---------------------------\n"), 00161 this->type_, 00162 this->cur_size_, 00163 this->max_size_, 00164 this->flags_, 00165 this->base_, 00166 this->locking_strategy_, 00167 this->reference_count_)); 00168 this->allocator_strategy_->dump (); 00169 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00170 #endif /* ACE_HAS_DUMP */ 00171 }
ACE_Data_Block * ACE_Data_Block::duplicate | ( | void | ) |
Return a "shallow" copy that increments our reference count by 1.
Definition at line 986 of file Message_Block.cpp.
References ACE_GUARD_RETURN, ACE_TRACE, and reference_count_.
Referenced by ACE_Message_Block::ACE_Message_Block(), ACE_InputCDR::operator=(), and ACE_InputCDR::steal_from().
00987 { 00988 ACE_TRACE ("ACE_Data_Block::duplicate"); 00989 00990 // Create a new <ACE_Message_Block>, but share the <base_> pointer 00991 // data (i.e., don't copy that). 00992 if (this->locking_strategy_) 00993 { 00994 // We need to acquire the lock before incrementing the count. 00995 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->locking_strategy_, 0); 00996 ++this->reference_count_; 00997 } 00998 else 00999 ++this->reference_count_; 01000 01001 return this; 01002 }
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, base_, and max_size_.
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, and flags_.
Referenced by ACE_Locked_Data_Block< ACE_LOCK >::clone_nocopy(), and ACE_Message_Block::flags().
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().
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, base_, and cur_size_.
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 | ) |
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, and type_.
Referenced by ACE_Locked_Data_Block< ACE_LOCK >::clone_nocopy(), and ACE_Message_Block::msg_type().
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 200 of file Message_Block.cpp.
References ACE_GUARD_RETURN, and reference_count_i().
Referenced by ACE_Message_Block::reference_count().
00201 { 00202 if (this->locking_strategy_) 00203 { 00204 // We need to acquire the lock before retrieving the count 00205 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->locking_strategy_, 0); 00206 00207 return this->reference_count_i (); 00208 } 00209 00210 return this->reference_count_i (); 00211 }
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.
References reference_count_.
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 this
and mb and return 0. Behavior is undefined if reference count < 0.
Definition at line 836 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(), and ACE_Message_Block::init_i().
00837 { 00838 ACE_TRACE ("ACE_Data_Block::release"); 00839 00840 ACE_Allocator *allocator = this->data_block_allocator_; 00841 00842 ACE_Data_Block *result = this->release_no_delete (lock); 00843 00844 // We must delete this outside the scope of the locking_strategy_ 00845 // since otherwise we'd be trying to "release" through a deleted 00846 // pointer! 00847 if (result == 0) 00848 ACE_DES_FREE (this, 00849 allocator->free, 00850 ACE_Data_Block); 00851 return result; 00852 }
ACE_Data_Block * ACE_Data_Block::release_i | ( | void | ) | [protected, virtual] |
Internal release implementation.
Definition at line 775 of file Message_Block.cpp.
References ACE_ASSERT, ACE_TRACE, and reference_count_.
Referenced by release_no_delete().
00776 { 00777 ACE_TRACE ("ACE_Data_Block::release_i"); 00778 00779 ACE_ASSERT (this->reference_count_ > 0); 00780 00781 ACE_Data_Block *result = 0; 00782 00783 // decrement reference count 00784 --this->reference_count_; 00785 00786 if (this->reference_count_ == 0) 00787 // this will cause deletion of this 00788 result = 0; 00789 else 00790 result = this; 00791 00792 return result; 00793 }
ACE_Data_Block * ACE_Data_Block::release_no_delete | ( | ACE_Lock * | lock | ) | [protected] |
Definition at line 796 of file Message_Block.cpp.
References ACE_GUARD_RETURN, ACE_TRACE, locking_strategy_, and release_i().
Referenced by release().
00797 { 00798 ACE_TRACE ("ACE_Data_Block::release_no_delete"); 00799 00800 ACE_Data_Block *result = 0; 00801 ACE_Lock *lock_to_be_used = 0; 00802 00803 // Check if we were passed in a lock 00804 if (lock != 0) 00805 { 00806 // Make sure that the lock passed in and our lock are the same 00807 if (lock == this->locking_strategy_) 00808 // In this case no locking is required. 00809 lock_to_be_used = 0; 00810 00811 // The lock passed in does not match our lock 00812 else 00813 // Lock to be used is our lock 00814 lock_to_be_used = this->locking_strategy_; 00815 } 00816 // This is the case when no lock was passed in 00817 else 00818 // Lock to be used is our lock 00819 lock_to_be_used = this->locking_strategy_; 00820 00821 // If there's a locking strategy then we need to acquire the lock 00822 // before decrementing the count. 00823 if (lock_to_be_used != 0) 00824 { 00825 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock_to_be_used, 0); 00826 00827 result = this->release_i (); 00828 } 00829 else 00830 result = this->release_i (); 00831 00832 return result; 00833 }
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 73 of file Message_Block.inl.
References ACE_SET_BITS, and ACE_TRACE.
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 214 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::memcpy().
00215 { 00216 ACE_TRACE ("ACE_Data_Block::size"); 00217 00218 if (length <= this->max_size_) 00219 this->cur_size_ = length; 00220 else 00221 { 00222 // We need to resize! 00223 char *buf = 0; 00224 ACE_ALLOCATOR_RETURN (buf, 00225 (char *) this->allocator_strategy_->malloc (length), 00226 -1); 00227 00228 ACE_OS::memcpy (buf, 00229 this->base_, 00230 this->cur_size_); 00231 if (ACE_BIT_DISABLED (this->flags_, 00232 ACE_Message_Block::DONT_DELETE)) 00233 this->allocator_strategy_->free ((void *) this->base_); 00234 else 00235 // We now assume ownership. 00236 ACE_CLR_BITS (this->flags_, 00237 ACE_Message_Block::DONT_DELETE); 00238 this->max_size_ = length; 00239 this->cur_size_ = length; 00240 this->base_ = buf; 00241 } 00242 return 0; 00243 }
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, and cur_size_.
Referenced by ACE_InputCDR::ACE_InputCDR(), ACE_InputCDR::clone_from(), clone_nocopy(), ACE_Message_Block::init_i(), and ACE_Message_Block::size().
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 810 of file Message_Block.h.
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 834 of file Message_Block.h.
Referenced by ACE_Message_Block::access_allocators(), 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 826 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 817 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 853 of file Message_Block.h.
Referenced by ACE_Message_Block::access_allocators(), clone_nocopy(), data_block_allocator(), release(), and ACE_Message_Block::reset_allocators().
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 842 of file Message_Block.h.
Referenced by ACE_Locked_Data_Block< ACE_LOCK >::ACE_Locked_Data_Block(), locking_strategy(), and release_no_delete().
size_t ACE_Data_Block::max_size_ [protected] |
Total size of buffer.
Definition at line 820 of file Message_Block.h.
Referenced by ACE_Data_Block(), base(), capacity(), clone_nocopy(), 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_Blocks.
Definition at line 850 of file Message_Block.h.
Referenced by duplicate(), reference_count_i(), release_i(), and ~ACE_Data_Block().