#include <Message_Block.h>
Collaboration diagram for ACE_Message_Block:

Public Types | |
| typedef int | ACE_Message_Type |
| typedef unsigned long | Message_Flags |
| enum | { MB_DATA = 0x01, MB_PROTO = 0x02, MB_BREAK = 0x03, MB_PASSFP = 0x04, MB_EVENT = 0x05, MB_SIG = 0x06, MB_IOCTL = 0x07, MB_SETOPTS = 0x08, MB_IOCACK = 0x81, MB_IOCNAK = 0x82, MB_PCPROTO = 0x83, MB_PCSIG = 0x84, MB_READ = 0x85, MB_FLUSH = 0x86, MB_STOP = 0x87, MB_START = 0x88, MB_HANGUP = 0x89, MB_ERROR = 0x8a, MB_PCEVENT = 0x8b, MB_NORMAL = 0x00, MB_PRIORITY = 0x80, MB_USER = 0x200 } |
| enum | { DONT_DELETE = 01, USER_FLAGS = 0x1000 } |
Public Member Functions | |
| ACE_Message_Block (ACE_Allocator *message_block_allocator=0) | |
| Create an empty message. | |
| ACE_Message_Block (ACE_Data_Block *, Message_Flags flags=0, ACE_Allocator *message_block_allocator=0) | |
| ACE_Message_Block (const char *data, size_t size=0, unsigned long priority=ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY) | |
| ACE_Message_Block (size_t size, ACE_Message_Type type=MB_DATA, ACE_Message_Block *cont=0, const char *data=0, ACE_Allocator *allocator_strategy=0, ACE_Lock *locking_strategy=0, unsigned long priority=ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY, const ACE_Time_Value &execution_time=ACE_Time_Value::zero, const ACE_Time_Value &deadline_time=ACE_Time_Value::max_time, ACE_Allocator *data_block_allocator=0, ACE_Allocator *message_block_allocator=0) | |
| ACE_Message_Block (const ACE_Message_Block &mb, size_t align) | |
| int | init (const char *data, size_t size=0) |
| int | init (size_t size, ACE_Message_Type type=MB_DATA, ACE_Message_Block *cont=0, const char *data=0, ACE_Allocator *allocator_strategy=0, ACE_Lock *locking_strategy=0, unsigned long priority=ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY, const ACE_Time_Value &execution_time=ACE_Time_Value::zero, const ACE_Time_Value &deadline_time=ACE_Time_Value::max_time, ACE_Allocator *data_block_allocator=0, ACE_Allocator *message_block_allocator=0) |
| virtual | ~ACE_Message_Block (void) |
| ACE_Message_Type | msg_type (void) const |
| Get type of the message. | |
| void | msg_type (ACE_Message_Type type) |
| Set type of the message. | |
| int | is_data_msg (void) const |
| Find out what type of message this is. | |
| ACE_Message_Type | msg_class (void) const |
| Message_Flags | set_flags (Message_Flags more_flags) |
| Message_Flags | clr_flags (Message_Flags less_flags) |
| Message_Flags | flags (void) const |
| Get the current message flags. | |
| Message_Flags | set_self_flags (ACE_Message_Block::Message_Flags more_flags) |
| Message_Flags | clr_self_flags (ACE_Message_Block::Message_Flags less_flags) |
| Message_Flags | self_flags (void) const |
| Get the current message flags. | |
| unsigned long | msg_priority (void) const |
| Get priority of the message. | |
| void | msg_priority (unsigned long priority) |
| Set priority of the message. | |
| const ACE_Time_Value & | msg_execution_time (void) const |
| Get execution time associated with the message. | |
| void | msg_execution_time (const ACE_Time_Value &et) |
| Set execution time associated with the message. | |
| const ACE_Time_Value & | msg_deadline_time (void) const |
| Get absolute time of deadline associated with the message. | |
| void | msg_deadline_time (const ACE_Time_Value &dt) |
| Set absolute time of deadline associated with the message. | |
| virtual ACE_Message_Block * | clone (Message_Flags mask=0) const |
| virtual ACE_Message_Block * | duplicate (void) const |
| Return a "shallow" copy that increments our reference count by 1. | |
| virtual ACE_Message_Block * | release (void) |
| int | copy (const char *buf, size_t n) |
| int | copy (const char *buf) |
| int | crunch (void) |
| void | reset (void) |
| void | access_allocators (ACE_Allocator *&allocator_strategy, ACE_Allocator *&data_block_allocator, ACE_Allocator *&message_block_allocator) |
| void | reset_allocators (ACE_Allocator *allocator_strategy=0, ACE_Allocator *data_block_allocator=0, ACE_Allocator *message_block_allocator=0) |
| char * | base (void) const |
| Get message data. | |
| void | base (char *data, size_t size, Message_Flags=DONT_DELETE) |
| Set message data (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 |
| char * | rd_ptr (void) const |
| Get the read pointer. | |
| void | rd_ptr (char *ptr) |
| Set the read pointer to ptr. | |
| void | rd_ptr (size_t n) |
| Set the read pointer ahead n bytes. | |
| char * | wr_ptr (void) const |
| Get the write pointer. | |
| void | wr_ptr (char *ptr) |
| Set the write pointer to ptr. | |
| void | wr_ptr (size_t n) |
| ACE_Data_Block * | data_block (void) const |
| void | data_block (ACE_Data_Block *) |
| ACE_Data_Block * | replace_data_block (ACE_Data_Block *) |
| ACE_Message_Block * | cont (void) const |
| Get the continuation field. | |
| void | cont (ACE_Message_Block *) |
| Set the continuation field. | |
| ACE_Message_Block * | next (void) const |
| Get link to next message. | |
| void | next (ACE_Message_Block *) |
| Set link to next message. | |
| ACE_Message_Block * | prev (void) const |
| Get link to prev message. | |
| void | prev (ACE_Message_Block *) |
| Set link to prev message. | |
| 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. | |
| int | reference_count (void) const |
| Get the current reference count. | |
| void | dump (void) const |
| Dump the state of an object. | |
Message length and size operations | |
Message length is (wr_ptr - rd_ptr).
Message size is capacity of the message, including data outside the [rd_ptr,wr_ptr] range. | |
| size_t | length (void) const |
| Get the length of the message. | |
| void | length (size_t n) |
| Set the length of the message. | |
| size_t | total_length (void) const |
| size_t | total_size (void) const |
| void | total_size_and_length (size_t &mb_size, size_t &mb_length) const |
| size_t | size (void) const |
| int | size (size_t length) |
| size_t | total_capacity (void) const |
| size_t | capacity (void) const |
| Get the number of allocated bytes in the top-level . | |
| size_t | space (void) const |
Static Public Member Functions | |
| ACE_Message_Block * | duplicate (const ACE_Message_Block *mb) |
| ACE_Message_Block * | release (ACE_Message_Block *mb) |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Protected Member Functions | |
| ACE_Message_Block (size_t size, ACE_Message_Type type, ACE_Message_Block *cont, const char *data, ACE_Allocator *allocator_strategy, ACE_Lock *locking_strategy, Message_Flags flags, unsigned long priority, const ACE_Time_Value &execution_time, const ACE_Time_Value &deadline_time, ACE_Data_Block *db, ACE_Allocator *data_block_allocator, ACE_Allocator *message_block_allocator) | |
| Perform the actual initialization. | |
| int | release_i (ACE_Lock *lock) |
| int | init_i (size_t size, ACE_Message_Type type, ACE_Message_Block *cont, const char *data, ACE_Allocator *allocator_strategy, ACE_Lock *locking_strategy, Message_Flags flags, unsigned long priority, const ACE_Time_Value &execution_time, const ACE_Time_Value &deadline_time, ACE_Data_Block *db, ACE_Allocator *data_block_allocator, ACE_Allocator *message_block_allocator) |
| Perform the actual initialization. | |
Protected Attributes | |
| size_t | rd_ptr_ |
| Pointer to beginning of next read. | |
| size_t | wr_ptr_ |
| Pointer to beginning of next write. | |
| unsigned long | priority_ |
| Priority of message. | |
| ACE_Message_Block * | cont_ |
| Pointer to next message block in the chain. | |
| ACE_Message_Block * | next_ |
| Pointer to next message in the list. | |
| ACE_Message_Block * | prev_ |
| Pointer to previous message in the list. | |
| ACE_Message_Block::Message_Flags | flags_ |
| Misc flags (e.g., DONT_DELETE and USER_FLAGS). | |
| ACE_Data_Block * | data_block_ |
| ACE_Allocator * | message_block_allocator_ |
Private Member Functions | |
| ACE_Message_Block & | operator= (const ACE_Message_Block &) |
| ACE_Message_Block (const ACE_Message_Block &) | |
Friends | |
| class | ACE_Data_Block |
An ACE_Message_Block is modeled after the message data structures used in System V STREAMS. Its purpose is to enable efficient manipulation of arbitrarily large messages without incurring much memory copying overhead. Here are the main characteristics of an ACE_Message_Block:
Definition at line 59 of file Message_Block.h.
|
|
Definition at line 119 of file Message_Block.h. Referenced by ACE_Data_Block::ACE_Data_Block(), ACE_Locked_Data_Block< ACE_LOCK >::ACE_Locked_Data_Block(), ACE_Message_Block(), clone(), duplicate(), init(), init_i(), is_data_msg(), msg_type(), and ACE_Data_Block::msg_type(). |
|
|
|
Definition at line 64 of file Message_Block.h.
00065 {
00066 // = Data and proto
00067 /// Undifferentiated data message
00068 MB_DATA = 0x01,
00069 /// Undifferentiated protocol control
00070 MB_PROTO = 0x02,
00071
00072 // = Control messages
00073 /// Line break (regular and priority)
00074 MB_BREAK = 0x03,
00075 /// Pass file pointer
00076 MB_PASSFP = 0x04,
00077 /// Post an event to an event queue
00078 MB_EVENT = 0x05,
00079 /// Generate process signal
00080 MB_SIG = 0x06,
00081 /// ioctl; set/get params
00082 MB_IOCTL = 0x07,
00083 /// Set various stream head options
00084 MB_SETOPTS = 0x08,
00085
00086 // = Control messages
00087 /// Acknowledge ioctl (high priority; go to head of queue)
00088 MB_IOCACK = 0x81,
00089 /// Negative ioctl acknowledge
00090 MB_IOCNAK = 0x82,
00091 /// Priority proto message
00092 MB_PCPROTO = 0x83,
00093 /// Generate process signal
00094 MB_PCSIG = 0x84,
00095 /// Generate read notification
00096 MB_READ = 0x85,
00097 /// Flush your queues
00098 MB_FLUSH = 0x86,
00099 /// Stop transmission immediately
00100 MB_STOP = 0x87,
00101 /// Restart transmission after stop
00102 MB_START = 0x88,
00103 /// Line disconnect
00104 MB_HANGUP = 0x89,
00105 /// Fatal error used to set u.u_error
00106 MB_ERROR = 0x8a,
00107 /// Post an event to an event queue
00108 MB_PCEVENT = 0x8b,
00109
00110 // = Message class masks
00111 /// Normal priority message mask
00112 MB_NORMAL = 0x00,
00113 /// High priority control message mask
00114 MB_PRIORITY = 0x80,
00115 /// User-defined message mask
00116 MB_USER = 0x200
00117 };
|
|
|
Definition at line 122 of file Message_Block.h.
00123 {
00124 /// Don't delete the data on exit since we don't own it.
00125 DONT_DELETE = 01,
00126 /// user defined flags start here
00127 USER_FLAGS = 0x1000
00128 };
|
|
|
Create an empty message.
Definition at line 394 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, DONT_DELETE, init_i(), LM_ERROR, and MB_DATA. Referenced by clone(), and duplicate().
00395 : flags_ (0), 00396 data_block_ (0) 00397 { 00398 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00399 00400 if (this->init_i (0, // size 00401 MB_DATA, // type 00402 0, // cont 00403 0, // data 00404 0, // allocator 00405 0, // locking strategy 00406 ACE_Message_Block::DONT_DELETE, // flags 00407 0, // priority 00408 ACE_Time_Value::zero, // execution time 00409 ACE_Time_Value::max_time, // absolute time of deadline 00410 0, // data block 00411 0, // data_block allocator 00412 message_block_allocator) == -1) // message_block allocator 00413 ACE_ERROR ((LM_ERROR, 00414 ACE_LIB_TEXT ("ACE_Message_Block"))); 00415 } |
|
||||||||||||||||
|
Create an ACE_Message_Block that owns the specified ACE_Data_Block without copying it. If the flags is set to Definition at line 537 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, ACE_Data_Block::data_block_allocator(), init_i(), LM_ERROR, MB_NORMAL, and Message_Flags.
00540 : flags_ (flags), 00541 data_block_ (0) 00542 { 00543 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00544 00545 if (this->init_i (0, // size 00546 MB_NORMAL, // type 00547 0, // cont 00548 0, // data 00549 0, // allocator 00550 0, // locking strategy 00551 0, // flags 00552 0, // priority 00553 ACE_Time_Value::zero, // execution time 00554 ACE_Time_Value::max_time, // absolute time of deadline 00555 data_block, // data block 00556 data_block->data_block_allocator (), 00557 message_block_allocator) == -1) 00558 ACE_ERROR ((LM_ERROR, 00559 ACE_LIB_TEXT ("ACE_Message_Block"))); 00560 } |
|
||||||||||||||||
|
Create an ACE_Message_Block that refers to data without copying it. The data memory will not be freed when this block is destroyed; memory management of data is left to the caller. Note that the Definition at line 369 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, DONT_DELETE, init_i(), LM_ERROR, and MB_DATA.
00372 : flags_ (0), 00373 data_block_ (0) 00374 { 00375 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00376 00377 if (this->init_i (size, // size 00378 MB_DATA, // type 00379 0, // cont 00380 data, // data 00381 0, // allocator 00382 0, // locking strategy 00383 ACE_Message_Block::DONT_DELETE, // flags 00384 priority, // priority 00385 ACE_Time_Value::zero, // execution time 00386 ACE_Time_Value::max_time, // absolute time of deadline 00387 0, // data block 00388 0, // data_block allocator 00389 0) == -1) // message_block allocator 00390 ACE_ERROR ((LM_ERROR, 00391 ACE_LIB_TEXT ("ACE_Message_Block"))); 00392 } |
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Create an initialized message of type type containing size bytes. The cont argument initializes the continuation field in the ACE_Message_Block. If data == 0 then this block allocates and owns the block's memory, using allocator to get the data if it's non-0. If data != 0 then this block refers to that memory until this this block ceases to exist; this object will not free data on destruction. If locking_strategy is non-0 then this is used to protect regions of code that access shared state (e.g., reference counting) from race conditions. Note that the
Definition at line 417 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_Message_Type, ACE_TRACE, DONT_DELETE, init_i(), and LM_ERROR.
00428 :flags_ (0), 00429 data_block_ (0) 00430 { 00431 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00432 00433 if (this->init_i (size, 00434 msg_type, 00435 msg_cont, 00436 msg_data, 00437 allocator_strategy, 00438 locking_strategy, 00439 msg_data ? ACE_Message_Block::DONT_DELETE : 0, 00440 priority, 00441 execution_time, 00442 deadline_time, 00443 0, // data block 00444 data_block_allocator, 00445 message_block_allocator) == -1) 00446 ACE_ERROR ((LM_ERROR, 00447 ACE_LIB_TEXT ("ACE_Message_Block"))); 00448 } |
|
||||||||||||
|
A copy constructor. This constructor is a bit different. If the incoming Message Block has a data block from the stack this constructor does a deep copy ie. allocates a new data block on the heap and does a copy of the data from the incoming message block. As a final note, the alignment information is used to align the data block if it is created afresh. If the incoming has a data block has a data block allocated from the heap, then this constructor just duplicates (ie. a shallow copy) the data block of the incoming mb. Definition at line 562 of file Message_Block.cpp. References ACE_BIT_DISABLED, ACE_ERROR, ACE_LIB_TEXT, ACE_ptr_align_binary, ACE_TRACE, base(), ACE_Data_Block::clone_nocopy(), data_block(), ACE_Data_Block::data_block_allocator(), DONT_DELETE, ACE_Data_Block::duplicate(), flags_, init_i(), LM_ERROR, MB_NORMAL, ACE_OS::memcpy(), message_block_allocator_, rd_ptr(), wr_ptr(), and wr_ptr_.
00564 :flags_ (0), 00565 data_block_ (0) 00566 { 00567 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00568 00569 if (ACE_BIT_DISABLED (mb.flags_, 00570 ACE_Message_Block::DONT_DELETE)) 00571 { 00572 if (this->init_i (0, // size 00573 MB_NORMAL, // type 00574 0, // cont 00575 0, // data 00576 0, // allocator 00577 0, // locking strategy 00578 0, // flags 00579 0, // priority 00580 ACE_Time_Value::zero, // execution time 00581 ACE_Time_Value::max_time, // absolute time of deadline 00582 mb.data_block ()->duplicate (), // data block 00583 mb.data_block ()->data_block_allocator (), 00584 mb.message_block_allocator_) == -1) 00585 ACE_ERROR ((LM_ERROR, 00586 ACE_LIB_TEXT ("ACE_Message_Block"))); 00587 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 00588 // Align ourselves 00589 char *start = ACE_ptr_align_binary (this->base (), 00590 align); 00591 #else 00592 char *start = this->base (); 00593 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00594 00595 // Set our rd & wr pointers 00596 this->rd_ptr (start); 00597 this->wr_ptr (start); 00598 00599 } 00600 else 00601 { 00602 if (this->init_i (0, // size 00603 MB_NORMAL, // type 00604 0, // cont 00605 0, // data 00606 0, // allocator 00607 0, // locking strategy 00608 0, // flags 00609 0, // priority 00610 ACE_Time_Value::zero, // execution time 00611 ACE_Time_Value::max_time, // absolute time of deadline 00612 mb.data_block ()->clone_nocopy (),// data block 00613 mb.data_block ()->data_block_allocator (), 00614 mb.message_block_allocator_) == -1) 00615 ACE_ERROR ((LM_ERROR, 00616 ACE_LIB_TEXT ("ACE_Message_Block"))); 00617 00618 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 00619 // Align ourselves 00620 char *start = ACE_ptr_align_binary (this->base (), 00621 align); 00622 #else 00623 char *start = this->base (); 00624 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00625 00626 // Set our rd & wr pointers 00627 this->rd_ptr (start); 00628 this->wr_ptr (start); 00629 00630 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 00631 // Get the alignment offset of the incoming ACE_Message_Block 00632 start = ACE_ptr_align_binary (mb.base (), 00633 align); 00634 #else 00635 start = mb.base (); 00636 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00637 00638 // Actual offset for the incoming message block assuming that it 00639 // is also aligned to the same "align" byte 00640 size_t const wr_offset = mb.wr_ptr_ - (start - mb.base ()); 00641 00642 // Copy wr_offset amount of data in to <this->data_block> 00643 (void) ACE_OS::memcpy (this->wr_ptr (), 00644 start, 00645 wr_offset); 00646 00647 // Dont move the write pointer, just leave it to the application 00648 // to do what it wants 00649 00650 } 00651 #if defined (ACE_LACKS_CDR_ALIGNMENT) 00652 ACE_UNUSED_ARG (align); 00653 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00654 } |
|
|
Delete all the resources held in the message. Note that <release()> is designed to release the continuation chain; the destructor is not. See <release()> for details. Definition at line 944 of file Message_Block.cpp. References ACE_BIT_DISABLED, ACE_TRACE, data_block(), DONT_DELETE, and ACE_Data_Block::release().
00945 {
00946 ACE_TRACE ("ACE_Message_Block::~ACE_Message_Block");
00947
00948 if (ACE_BIT_DISABLED (this->flags_,
00949 ACE_Message_Block::DONT_DELETE)&&
00950 this->data_block ())
00951 this->data_block ()->release ();
00952
00953 this->prev_ = 0;
00954 this->next_ = 0;
00955 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Perform the actual initialization.
Definition at line 502 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_Message_Type, ACE_TRACE, init_i(), LM_ERROR, and Message_Flags.
00515 : flags_ (0), 00516 data_block_ (0) 00517 { 00518 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00519 00520 if (this->init_i (size, 00521 msg_type, 00522 msg_cont, 00523 msg_data, 00524 allocator_strategy, 00525 locking_strategy, 00526 flags, 00527 priority, 00528 execution_time, 00529 deadline_time, 00530 db, 00531 data_block_allocator, 00532 message_block_allocator) == -1) 00533 ACE_ERROR ((LM_ERROR, 00534 ACE_LIB_TEXT ("ACE_Message_Block"))); 00535 } |
|
|
|
|
||||||||||||||||
|
This method returns the allocators only from the first message block in the chain.
Definition at line 272 of file Message_Block.inl. References ACE_Data_Block::allocator_strategy_, data_block_, ACE_Data_Block::data_block_allocator_, and message_block_allocator_.
00275 {
00276 allocator_strategy =
00277 this->data_block_->allocator_strategy_;
00278 data_block_allocator =
00279 this->data_block_->data_block_allocator_;
00280 message_block_allocator =
00281 this->message_block_allocator_;
00282 }
|
|
||||||||||||||||
|
Set message data (doesn't reallocate).
Definition at line 292 of file Message_Block.inl. References ACE_TRACE, ACE_Data_Block::base(), data_block(), Message_Flags, rd_ptr_, and wr_ptr_.
00295 {
00296 ACE_TRACE ("ACE_Message_Block::base");
00297 this->rd_ptr_ = 0;
00298 this->wr_ptr_ = 0;
00299 this->data_block ()->base (msg_data, msg_length, msg_flags);
00300 }
|
|
|
|
Get the number of allocated bytes in the top-level .
Definition at line 154 of file Message_Block.inl. References ACE_TRACE, ACE_Data_Block::capacity(), and data_block(). Referenced by total_capacity().
00155 {
00156 ACE_TRACE ("ACE_Message_Block::capacity");
00157 return this->data_block ()->capacity ();
00158 }
|
|
|
Return an exact "deep copy" of the message, i.e., create fresh new copies of all the Data_Blocks and continuations. Definition at line 1127 of file Message_Block.cpp. References ACE_DEADLINE_TIME, ACE_EXECUTION_TIME, ACE_Message_Block(), ACE_Message_Type, ACE_NEW_RETURN, ACE_TRACE, ACE_Data_Block::clone(), cont(), cont_, data_block(), ACE_Data_Block::data_block_allocator(), ACE_Allocator::malloc(), message_block_allocator_, Message_Flags, rd_ptr(), release(), ACE_Data_Block::release(), and wr_ptr(). Referenced by ACE_InputCDR::steal_contents().
01128 {
01129 ACE_TRACE ("ACE_Message_Block::clone");
01130
01131 // Get a pointer to a "cloned" <ACE_Data_Block> (will copy the
01132 // values rather than increment the reference count).
01133 ACE_Data_Block *db = this->data_block ()->clone (mask);
01134
01135 if (db == 0)
01136 return 0;
01137
01138 ACE_Message_Block *nb = 0;
01139
01140 if(message_block_allocator_ == 0)
01141 {
01142 ACE_NEW_RETURN (nb,
01143 ACE_Message_Block (0, // size
01144 ACE_Message_Type (0), // type
01145 0, // cont
01146 0, // data
01147 0, // allocator
01148 0, // locking strategy
01149 0, // flags
01150 this->priority_, // priority
01151 ACE_EXECUTION_TIME, // execution time
01152 ACE_DEADLINE_TIME, // absolute time to deadline
01153 // Get a pointer to a
01154 // "duplicated" <ACE_Data_Block>
01155 // (will simply increment the
01156 // reference count).
01157 db,
01158 db->data_block_allocator (),
01159 this->message_block_allocator_),
01160 0);
01161 }
01162 else
01163 {
01164 // This is the ACE_NEW_MALLOC macro with the return check removed.
01165 // We need to do it this way because if it fails we need to release
01166 // the cloned data block that was created above. If we used
01167 // ACE_NEW_MALLOC_RETURN, there would be a memory leak because the
01168 // above db pointer would be left dangling.
01169 nb = static_cast<ACE_Message_Block*> (message_block_allocator_->malloc (sizeof (ACE_Message_Block)));
01170 if(nb != 0)
01171 new (nb) ACE_Message_Block (0, // size
01172 ACE_Message_Type (0), // type
01173 0, // cont
01174 0, // data
01175 0, // allocator
01176 0, // locking strategy
01177 0, // flags
01178 this->priority_, // priority
01179 ACE_EXECUTION_TIME, // execution time
01180 ACE_DEADLINE_TIME, // absolute time to deadline
01181 db,
01182 db->data_block_allocator (),
01183 this->message_block_allocator_);
01184 }
01185
01186 if (nb == 0)
01187 {
01188 db->release ();
01189 return 0;
01190 }
01191
01192 // Set the read and write pointers in the new <Message_Block> to the
01193 // same relative offset as in the existing <Message_Block>.
01194 nb->rd_ptr (this->rd_ptr_);
01195 nb->wr_ptr (this->wr_ptr_);
01196
01197 // Clone all the continuation messages if necessary.
01198 if (this->cont () != 0
01199 && (nb->cont_ = this->cont ()->clone (mask)) == 0)
01200 {
01201 nb->release ();
01202 return 0;
01203 }
01204 return nb;
01205 }
|
|
|
Clear the message flag bits specified in less_flags and return the new value. Definition at line 112 of file Message_Block.inl. References ACE_TRACE, ACE_Data_Block::clr_flags(), data_block(), and Message_Flags.
00113 {
00114 ACE_TRACE ("ACE_Message_Block::clr_flags");
00115 return this->data_block ()->clr_flags (less_flags);
00116 }
|
|
|
Clear the message flag bits specified in less_flags and return the new value. Definition at line 24 of file Message_Block.inl. References ACE_CLR_BITS, ACE_TRACE, and Message_Flags. Referenced by ACE_InputCDR::clone_from(), ACE_InputCDR::exchange_data_blocks(), ACE_CDR::grow(), ACE_InputCDR::reset_contents(), ACE_InputCDR::steal_contents(), and ACE_InputCDR::steal_from().
00025 {
00026 ACE_TRACE ("ACE_Message_Block::clr_self_flags");
00027 // Later we might mask more_flags so that user can't change internal
00028 // ones: less_flags &= ~(USER_FLAGS -1).
00029 return ACE_CLR_BITS (this->flags_, less_flags);
00030 }
|
|
|
Set the continuation field.
Definition at line 409 of file Message_Block.inl. References ACE_TRACE, and cont_.
|
|
|
|
Copies a 0-terminated character string into this ACE_Message_Block. The string is copied into the block starting at the current write pointer. The 0-terminator is included in the copied data.
Definition at line 99 of file Message_Block.cpp. References ACE_TRACE, ACE_OS::memcpy(), space(), ACE_OS::strlen(), and wr_ptr().
00100 {
00101 ACE_TRACE ("ACE_Message_Block::copy");
00102
00103 /* size_t len = static_cast<size_t> (this->end () - this->wr_ptr ()); */
00104 // Note that for this to work correct, end() *must* be >= wr_ptr().
00105 size_t len = this->space ();
00106
00107 size_t buflen = ACE_OS::strlen (buf) + 1;
00108
00109 if (len < buflen)
00110 return -1;
00111 else
00112 {
00113 (void) ACE_OS::memcpy (this->wr_ptr (),
00114 buf,
00115 buflen);
00116 this->wr_ptr (buflen);
00117 return 0;
00118 }
00119 }
|
|
||||||||||||
|
Copies data into this ACE_Message_Block. Data is copied into the block starting at the current write pointer.
Definition at line 78 of file Message_Block.cpp. References ACE_TRACE, ACE_OS::memcpy(), space(), and wr_ptr(). Referenced by ACE_InputCDR::ACE_InputCDR(), ACE_CDR::consolidate(), ACE_CDR::grow(), and ACE_UPIPE_Stream::send().
00079 {
00080 ACE_TRACE ("ACE_Message_Block::copy");
00081
00082 /*size_t len = static_cast<size_t> (this->end () - this->wr_ptr ());*/
00083 // Note that for this to work correct, end () *must* be >= mark ().
00084 size_t len = this->space ();
00085
00086 if (len < n)
00087 return -1;
00088 else
00089 {
00090 (void) ACE_OS::memcpy (this->wr_ptr (),
00091 buf,
00092 n);
00093 this->wr_ptr (n);
00094 return 0;
00095 }
00096 }
|
|
|
Normalizes data in the top-level to align with the base, i.e., it "shifts" the data pointed to by down to the and then readjusts to point to and to point to + the length of the moved data. Returns -1 and does nothing if the is > , else 0 on success. Definition at line 122 of file Message_Block.cpp. References length(), ACE_OS::memmove(), rd_ptr(), rd_ptr_, wr_ptr(), and wr_ptr_.
00123 {
00124 if (this->rd_ptr_ != 0)
00125 {
00126 if (this->rd_ptr_ > this->wr_ptr_)
00127 return -1;
00128
00129 size_t const len = this->length ();
00130 (void) ACE_OS::memmove (this->base (),
00131 this->rd_ptr (),
00132 len);
00133 this->rd_ptr (this->base ());
00134 this->wr_ptr (this->base () + len);
00135 }
00136 return 0;
00137 }
|
|
|
Set a new data block pointer. The original ACE_Data_Block is released as a result of this call. If you need to keep the original block, call instead. Upon return, this ACE_Message_Block holds a pointer to the new ACE_Data_Block, taking over the reference you held on it prior to the call. Definition at line 61 of file Message_Block.cpp. References ACE_BIT_DISABLED, ACE_TRACE, data_block_, DONT_DELETE, rd_ptr(), ACE_Data_Block::release(), and wr_ptr().
00062 {
00063 ACE_TRACE ("ACE_Message_Block::data_block");
00064 if (ACE_BIT_DISABLED (this->flags_,
00065 ACE_Message_Block::DONT_DELETE)
00066 && this->data_block_ != 0)
00067 this->data_block_->release ();
00068
00069 this->data_block_ = db;
00070
00071 // Set the read and write pointers in the <Message_Block> to point
00072 // to the buffer in the <ACE_Data_Block>.
00073 this->rd_ptr (this->data_block ()->base ());
00074 this->wr_ptr (this->data_block ()->base ());
00075 }
|
|
|
Get a pointer to the data block. Note that the ACE_Message_Block still references the block; this call does not change the reference count. Definition at line 8 of file Message_Block.inl. References ACE_TRACE, and data_block_. Referenced by ACE_InputCDR::ACE_InputCDR(), ACE_Message_Block(), base(), capacity(), clone(), ACE_InputCDR::clone_from(), clr_flags(), dump(), duplicate(), end(), ACE_InputCDR::exchange_data_blocks(), flags(), ACE_CDR::grow(), ACE_OutputCDR::grow_and_adjust(), init_i(), locking_strategy(), mark(), msg_type(), ACE_InputCDR::operator=(), reference_count(), release(), release_i(), ACE_InputCDR::reset_contents(), set_flags(), size(), ACE_InputCDR::steal_contents(), ACE_InputCDR::steal_from(), ACE_OutputCDR::write_octet_array_mb(), and ~ACE_Message_Block().
00009 {
00010 ACE_TRACE ("ACE_Message_Block::data_block");
00011 return this->data_block_;
00012 }
|
|
|
Dump the state of an object.
Definition at line 168 of file Message_Block.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, data_block(), ACE_Data_Block::dump(), and LM_DEBUG.
00169 {
00170 #if defined (ACE_HAS_DUMP)
00171 ACE_TRACE ("ACE_Message_Block::dump");
00172 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00173 ACE_DEBUG ((LM_DEBUG,
00174 ACE_LIB_TEXT ("-----( Message Block )-----\n")
00175 ACE_LIB_TEXT ("priority_ = %d\n")
00176 ACE_LIB_TEXT ("next_ = %u\n")
00177 ACE_LIB_TEXT ("prev_ = %u\n")
00178 ACE_LIB_TEXT ("cont_ = %u\n")
00179 ACE_LIB_TEXT ("rd_ptr_ = %u\n")
00180 ACE_LIB_TEXT ("wr_ptr_ = %u\n")
00181 ACE_LIB_TEXT ("---------------------------\n"),
00182 this->priority_,
00183 this->next_,
00184 this->prev_,
00185 this->cont_,
00186 this->rd_ptr_,
00187 this->wr_ptr_));
00188 this->data_block ()->dump ();
00189 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00190 #endif /* ACE_HAS_DUMP */
00191 }
|
|
|
Return a "shallow" copy that increments our reference count by 1. This is similar to CORBA's method, which is useful if you want to eliminate lots of checks for NULL pointers before calling on them. Definition at line 1064 of file Message_Block.cpp. References ACE_TRACE, and duplicate().
|
|
|
Return a "shallow" copy that increments our reference count by 1.
Definition at line 985 of file Message_Block.cpp. References ACE_DEADLINE_TIME, ACE_EXECUTION_TIME, ACE_Message_Block(), ACE_Message_Type, ACE_NEW_MALLOC_RETURN, ACE_NEW_RETURN, ACE_TRACE, cont_, data_block(), ACE_Data_Block::data_block_allocator(), ACE_Allocator::malloc(), message_block_allocator_, rd_ptr(), release(), and wr_ptr(). Referenced by duplicate(), and ACE_POSIX_Asynch_Transmit_Handler::handle_write_stream().
00986 {
00987 ACE_TRACE ("ACE_Message_Block::duplicate");
00988
00989 ACE_Message_Block *nb = 0;
00990
00991 // Create a new <ACE_Message_Block> that contains unique copies of
00992 // the message block fields, but a reference counted duplicate of
00993 // the <ACE_Data_Block>.
00994
00995 // If there is no allocator, use the standard new and delete calls.
00996 if (this->message_block_allocator_ == 0)
00997 ACE_NEW_RETURN (nb,
00998 ACE_Message_Block (0, // size
00999 ACE_Message_Type (0), // type
01000 0, // cont
01001 0, // data
01002 0, // allocator
01003 0, // locking strategy
01004 0, // flags
01005 this->priority_, // priority
01006 ACE_EXECUTION_TIME,
01007 ACE_DEADLINE_TIME,
01008 // Get a pointer to a
01009 // "duplicated" <ACE_Data_Block>
01010 // (will simply increment the
01011 // reference count).
01012 this->data_block ()->duplicate (),
01013 this->data_block ()->data_block_allocator (),
01014 this->message_block_allocator_),
01015 0);
01016 else // Otherwise, use the message_block_allocator passed in.
01017 ACE_NEW_MALLOC_RETURN (nb,
01018 static_cast<ACE_Message_Block*> (
01019 message_block_allocator_->malloc (sizeof (ACE_Message_Block))),
01020 ACE_Message_Block (0, // size
01021 ACE_Message_Type (0), // type
01022 0, // cont
01023 0, // data
01024 0, // allocator
01025 0, // locking strategy
01026 0, // flags
01027 this->priority_, // priority
01028 ACE_EXECUTION_TIME,
01029 ACE_DEADLINE_TIME,
01030 // Get a pointer to a
01031 // "duplicated" <ACE_Data_Block>
01032 // (will simply increment the
01033 // reference count).
01034 this->data_block ()->duplicate (),
01035 this->data_block ()->data_block_allocator (),
01036 this->message_block_allocator_),
01037 0);
01038
01039 // Set the read and write pointers in the new <Message_Block> to the
01040 // same relative offset as in the existing <Message_Block>. Note
01041 // that we are assuming that the data_block()->base() pointer
01042 // doesn't change when it's duplicated.
01043 nb->rd_ptr (this->rd_ptr_);
01044 nb->wr_ptr (this->wr_ptr_);
01045
01046 // Increment the reference counts of all the continuation messages.
01047 if (this->cont_)
01048 {
01049 nb->cont_ = this->cont_->duplicate ();
01050
01051 // If things go wrong, release all of our resources and return
01052 // 0.
01053 if (nb->cont_ == 0)
01054 {
01055 nb->release ();
01056 nb = 0;
01057 }
01058 }
01059
01060 return nb;
01061 }
|
|
|
Return a pointer to 1 past the end of the allocated data in a message.
Definition at line 340 of file Message_Block.inl. References ACE_TRACE, data_block(), and ACE_Data_Block::end(). Referenced by ACE_InputCDR::ACE_InputCDR(), ACE_OutputCDR::adjust(), ACE_InputCDR::end(), and ACE_OutputCDR::write_octet_array_mb().
00341 {
00342 ACE_TRACE ("ACE_Message_Block::end");
00343 return this->data_block ()->end ();
00344 }
|
|
|
Get the current message flags.
Definition at line 119 of file Message_Block.inl. References ACE_TRACE, data_block(), and ACE_Data_Block::flags(). Referenced by ACE_OutputCDR::write_octet_array_mb().
00120 {
00121 ACE_TRACE ("ACE_Message_Block::flags");
00122 return this->data_block ()->flags ();
00123 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Create an initialized message of type type containing size bytes. The cont argument initializes the continuation field in the . If data == 0 then we create and own the data, using allocator_strategy to get the data if it's non-0. If data != 0 we assume that we have ownership of the data till this object ceases to exist (and don't delete it during destruction). If locking_strategy is non-0 then this is used to protect regions of code that access shared state (e.g., reference counting) from race conditions. Note that the of the will be size, but the will be 0 until is set. The data_block_allocator is use to allocate the data blocks while the allocator_strategy is used to allocate the buffers contained by those. Definition at line 451 of file Message_Block.cpp. References ACE_Message_Type, ACE_TRACE, DONT_DELETE, and init_i().
00462 {
00463 ACE_TRACE ("ACE_Message_Block::init");
00464
00465 return this->init_i (size,
00466 msg_type,
00467 msg_cont,
00468 msg_data,
00469 allocator_strategy,
00470 locking_strategy,
00471 msg_data ? ACE_Message_Block::DONT_DELETE : 0,
00472 priority,
00473 execution_time,
00474 deadline_time,
00475 0, // data block
00476 data_block_allocator,
00477 message_block_allocator);
00478 }
|
|
||||||||||||
|
Create a Message Block that assumes it has ownership of data, but in reality it doesnt (i.e., cannot delete it since it didn't malloc it!). Note that the Definition at line 481 of file Message_Block.cpp. References ACE_TRACE, DONT_DELETE, init_i(), and MB_DATA.
00483 {
00484 ACE_TRACE ("ACE_Message_Block::init");
00485 // Should we also initialize all the other fields, as well?
00486
00487 return this->init_i (size, // size
00488 MB_DATA, // type
00489 0, // cont
00490 data, // data
00491 0, // allocator
00492 0, // locking strategy
00493 ACE_Message_Block::DONT_DELETE, // flags
00494 0, // priority
00495 ACE_Time_Value::zero, // execution time
00496 ACE_Time_Value::max_time, // absolute time of deadline
00497 0, // data block
00498 0, // data_block allocator
00499 0); // message_block allocator
00500 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Perform the actual initialization.
Definition at line 657 of file Message_Block.cpp. References ACE_ALLOCATOR_RETURN, ACE_Data_Block, ACE_FUNCTION_TIMEPROBE, ACE_Message_Type, ACE_NEW_MALLOC_RETURN, ACE_TIMEPROBE, ACE_TRACE, cont_, data_block(), data_block_, ACE_Allocator::malloc(), message_block_allocator_, Message_Flags, rd_ptr_, ACE_Data_Block::release(), ACE_Data_Block::size(), and wr_ptr_. Referenced by ACE_Message_Block(), and init().
00670 {
00671 ACE_TRACE ("ACE_Message_Block::init_i");
00672 ACE_FUNCTION_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_ENTER);
00673
00674 this->rd_ptr_ = 0;
00675 this->wr_ptr_ = 0;
00676 this->priority_ = priority;
00677 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00678 this->execution_time_ = execution_time;
00679 this->deadline_time_ = deadline_time;
00680 #else
00681 ACE_UNUSED_ARG (execution_time);
00682 ACE_UNUSED_ARG (deadline_time);
00683 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00684 this->cont_ = msg_cont;
00685 this->next_ = 0;
00686 this->prev_ = 0;
00687
00688 this->message_block_allocator_ = message_block_allocator;
00689
00690 if (this->data_block_ != 0)
00691 {
00692 this->data_block_->release ();
00693 this->data_block_ = 0;
00694 }
00695
00696 if (db == 0)
00697 {
00698 if (data_block_allocator == 0)
00699 ACE_ALLOCATOR_RETURN (data_block_allocator,
00700 ACE_Allocator::instance (),
00701 -1);
00702
00703 ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_ALLOC);
00704
00705 // Allocate the <ACE_Data_Block> portion, which is reference
00706 // counted.
00707 ACE_NEW_MALLOC_RETURN (db,
00708 static_cast<ACE_Data_Block *> (
00709 data_block_allocator->malloc (sizeof (ACE_Data_Block))),
00710 ACE_Data_Block (size,
00711 msg_type,
00712 msg_data,
00713 allocator_strategy,
00714 locking_strategy,
00715 flags,
00716 data_block_allocator),
00717 -1);
00718 ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_CTOR);
00719 }
00720
00721 // Reset the data_block_ pointer.
00722 this->data_block (db);
00723 // If the data alloc failed, the ACE_Data_Block ctor can't relay
00724 // that directly. Therefore, need to check it explicitly.
00725 if (db->size () < size)
00726 return -1;
00727 return 0;
00728 }
|
|
|
Find out what type of message this is.
Definition at line 202 of file Message_Block.inl. References ACE_Message_Type, ACE_TRACE, MB_DATA, MB_PCPROTO, MB_PROTO, and msg_type().
00203 {
00204 ACE_TRACE ("ACE_Message_Block::is_data_msg");
00205 ACE_Message_Type mt = this->msg_type ();
00206 return
00207 mt == ACE_Message_Block::MB_DATA
00208 || mt == ACE_Message_Block::MB_PROTO
00209 || mt == ACE_Message_Block::MB_PCPROTO;
00210 }
|
|
|
Set the length of the message.
Definition at line 138 of file Message_Block.inl. References ACE_TRACE, rd_ptr_, and wr_ptr_.
|
|
|
|
Set a new locking strategy and return the hold one.
Definition at line 500 of file Message_Block.inl. References ACE_TRACE, data_block(), and ACE_Data_Block::locking_strategy().
00501 {
00502 ACE_TRACE ("ACE_Message_Block::locking_strategy");
00503 ACE_Lock *ols = this->data_block ()->locking_strategy ();
00504 this->data_block ()->locking_strategy (nls);
00505 return ols;
00506 }
|
|
|
Get the locking strategy.
Definition at line 493 of file Message_Block.inl. References ACE_TRACE, data_block(), and ACE_Data_Block::locking_strategy().
00494 {
00495 ACE_TRACE ("ACE_Message_Block::locking_strategy");
00496 return this->data_block ()->locking_strategy ();
00497 }
|
|
|
Return a pointer to 1 past the end of the allotted data in a message. Allotted data may be less than allocated data if a value smaller than capacity() to is passed to size(). Definition at line 326 of file Message_Block.inl. References ACE_TRACE, data_block(), and ACE_Data_Block::mark(). Referenced by space().
00327 {
00328 ACE_TRACE ("ACE_Message_Block::mark");
00329 return this->data_block ()->mark ();
00330 }
|
|
|
Find out what class of message this is (there are two classes, Definition at line 189 of file Message_Block.inl. References ACE_TRACE, MB_NORMAL, MB_PRIORITY, MB_USER, and msg_type().
00190 {
00191 ACE_TRACE ("ACE_Message_Block::msg_class");
00192
00193 if (this->msg_type () < ACE_Message_Block::MB_PRIORITY)
00194 return ACE_Message_Block::MB_NORMAL;
00195 else if (this->msg_type () < ACE_Message_Block::MB_USER)
00196 return ACE_Message_Block::MB_PRIORITY;
00197 else
00198 return ACE_Message_Block::MB_USER;
00199 }
|
|
|
Set absolute time of deadline associated with the message.
Definition at line 261 of file Message_Block.inl. References ACE_TRACE.
00262 {
00263 ACE_TRACE ("ACE_Message_Block::msg_deadline_time (const ACE_Time_Value & et)");
00264 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00265 this->deadline_time_ = dt;
00266 #else
00267 ACE_UNUSED_ARG (dt);
00268 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00269 }
|
|
|
Get absolute time of deadline associated with the message.
Definition at line 249 of file Message_Block.inl. References ACE_TRACE. Referenced by ACE_Laxity_Message_Strategy::convert_priority(), ACE_Deadline_Message_Strategy::convert_priority(), ACE_Message_Queue< ACE_SYNCH_USE >::dequeue_deadline_i(), and ACE_Message_Queue< ACE_SYNCH_USE >::enqueue_deadline_i().
00250 {
00251 ACE_TRACE ("ACE_Message_Block::msg_deadline_time (void)");
00252
00253 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00254 return this->deadline_time_;
00255 #else
00256 return ACE_Time_Value::max_time; // absolute time of deadline
00257 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00258 }
|
|
|
Set execution time associated with the message.
Definition at line 238 of file Message_Block.inl. References ACE_TRACE.
00239 {
00240 ACE_TRACE ("ACE_Message_Block::msg_execution_time (const ACE_Time_Value & et)");
00241 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00242 this->execution_time_ = et;
00243 #else
00244 ACE_UNUSED_ARG (et);
00245 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00246 }
|
|
|
Get execution time associated with the message.
Definition at line 227 of file Message_Block.inl. References ACE_TRACE. Referenced by ACE_Laxity_Message_Strategy::convert_priority().
00228 {
00229 ACE_TRACE ("ACE_Message_Block::msg_execution_time (void)");
00230 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00231 return this->execution_time_;
00232 #else
00233 return ACE_Time_Value::zero;
00234 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00235 }
|
|
|
Set priority of the message.
Definition at line 220 of file Message_Block.inl. References ACE_TRACE.
|
|
|
Get priority of the message.
Definition at line 213 of file Message_Block.inl. References ACE_TRACE. Referenced by ACE_Message_Queue< ACE_SYNCH_USE >::dequeue_prio_i(), ACE_Message_Queue< ACE_SYNCH_USE >::enqueue_i(), ACE_Dynamic_Message_Strategy::priority_status(), and ACE_Dynamic_Message_Queue<>::sublist_enqueue_i().
|
|
|
Set type of the message.
Definition at line 182 of file Message_Block.inl. References ACE_Message_Type, ACE_TRACE, data_block(), and ACE_Data_Block::msg_type().
00183 {
00184 ACE_TRACE ("ACE_Message_Block::msg_type");
00185 this->data_block ()->msg_type (t);
00186 }
|
|
|
Get type of the message.
Definition at line 175 of file Message_Block.inl. References ACE_TRACE, data_block(), and ACE_Data_Block::msg_type(). Referenced by ACE_Stream_Tail<>::control(), is_data_msg(), msg_class(), ACE_Stream_Tail<>::put(), and ACE_Stream_Head<>::put().
00176 {
00177 ACE_TRACE ("ACE_Message_Block::msg_type");
00178 return this->data_block ()->msg_type ();
00179 }
|
|
|
Set link to next message.
Definition at line 441 of file Message_Block.inl. References ACE_TRACE.
|
|
|
|
Definition at line 1209 of file Message_Block.cpp. References ACE_TRACE.
01210 {
01211 ACE_TRACE ("ACE_Message_Block::operator=");
01212 return *this;
01213 }
|
|
|
Set link to prev message.
Definition at line 455 of file Message_Block.inl. References ACE_TRACE.
|
|
|
|
Set the read pointer ahead n bytes.
Definition at line 355 of file Message_Block.inl. References ACE_TRACE, and rd_ptr_.
|
|
|
Set the read pointer to ptr.
Definition at line 348 of file Message_Block.inl. References ACE_TRACE, base(), and rd_ptr_.
|
|
|
|
Get the current reference count.
Definition at line 46 of file Message_Block.inl. References data_block(), and ACE_Data_Block::reference_count().
00047 {
00048 return data_block () ? data_block ()->reference_count () : 0;
00049 }
|
|
|
This behaves like the non-static method , except that it checks if is 0. This is similar to <CORBA::release>, which is useful if you want to eliminate lots of checks for NULL pointers before calling on them. Returns . Definition at line 934 of file Message_Block.cpp. References ACE_TRACE, and release().
|
|
|
Decrease the shared ACE_Data_Block's reference count by 1. If the ACE_Data_Block's reference count goes to 0, it is deleted. In all cases, this ACE_Message_Block is deleted - it must have come from the heap, or there will be trouble. release() is designed to release the continuation chain; the destructor is not. If we make the destructor release the continuation chain by calling release() or delete on the message blocks in the continuation chain, the following code will not work since the message block in the continuation chain is not off the heap: ACE_Message_Block mb1 (1024); ACE_Message_Block mb2 (1024); mb1.cont (&mb2); And hence, call release() on a dynamically allocated message block. This will release all the message blocks in the continuation chain. If you call delete or let the message block fall off the stack, cleanup of the message blocks in the continuation chain becomes the responsibility of the user.
Definition at line 827 of file Message_Block.cpp. References ACE_DES_FREE, ACE_GUARD_RETURN, ACE_TRACE, data_block(), ACE_Data_Block::data_block_allocator(), ACE_Allocator::free(), ACE_Data_Block::locking_strategy(), and release_i(). Referenced by ACE_Asynch_Acceptor< HANDLER >::accept(), ACE_Stream_Tail<>::canonical_flush(), ACE_Stream_Head<>::canonical_flush(), clone(), ACE_Stream<>::control(), ACE_Activation_Queue::dequeue(), ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >::dequeue_deadline(), ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >::dequeue_head(), ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >::dequeue_prio(), ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >::dequeue_tail(), duplicate(), ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >::enqueue_deadline(), ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >::enqueue_head(), ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >::enqueue_prio(), ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >::enqueue_tail(), ACE_Message_Queue< ACE_SYNCH_USE >::flush_i(), ACE_Asynch_Acceptor< HANDLER >::handle_accept(), ACE_WFMO_Reactor_Notify::handle_signal(), ACE_Future_Set< T >::next_readable(), ACE_WFMO_Reactor_Notify::notify(), ACE_WFMO_Reactor_Notify::purge_pending_notifications(), ACE_Stream_Tail<>::put(), ACE_UPIPE_Stream::recv(), release(), ACE_OutputCDR::reset(), ACE_OutputCDR::write_octet_array_mb(), ACE_OutputCDR::~ACE_OutputCDR(), ACE_POSIX_Asynch_Transmit_Handler::~ACE_POSIX_Asynch_Transmit_Handler(), and ACE_UPIPE_Stream::~ACE_UPIPE_Stream().
00828 {
00829 ACE_TRACE ("ACE_Message_Block::release");
00830
00831 // We want to hold the data block in a temporary variable because we
00832 // invoked "delete this;" at some point, so using this->data_block_
00833 // could be a bad idea.
00834 ACE_Data_Block *tmp = this->data_block ();
00835
00836 // This flag is set to 1 when we have to destroy the data_block
00837 int destroy_dblock = 0;
00838
00839 ACE_Lock *lock = 0;
00840
00841 // Do we have a valid data block
00842 if (this->data_block ())
00843 {
00844 // Grab the lock that belongs to my data block
00845 lock = this->data_block ()->locking_strategy ();
00846
00847 // if we have a lock
00848 if (lock != 0)
00849 {
00850 // One guard for all
00851 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock, 0);
00852
00853 // Call non-guarded release with <lock>
00854 destroy_dblock = this->release_i (lock);
00855 }
00856 // This is the case when we have a valid data block but no lock
00857 else
00858 // Call non-guarded release with no lock
00859 destroy_dblock = this->release_i (0);
00860 }
00861 else
00862 // This is the case when we don't even have a valid data block
00863 destroy_dblock = this->release_i (0);
00864
00865 if (destroy_dblock != 0)
00866 {
00867 ACE_Allocator *allocator = tmp->data_block_allocator ();
00868 ACE_DES_FREE (tmp,
00869 allocator->free,
00870 ACE_Data_Block);
00871 }
00872
00873 return 0;
00874 }
|
|
|
Internal release implementation Returns 1 if the data block has to be destroyed. Definition at line 877 of file Message_Block.cpp. References ACE_BIT_DISABLED, ACE_DES_FREE, ACE_TRACE, cont_, data_block(), data_block_, ACE_Data_Block::data_block_allocator(), DONT_DELETE, ACE_Allocator::free(), message_block_allocator_, and ACE_Data_Block::release_no_delete(). Referenced by release().
00878 {
00879 ACE_TRACE ("ACE_Message_Block::release_i");
00880
00881 // Free up all the continuation messages.
00882 if (this->cont_)
00883 {
00884 ACE_Message_Block *mb = this->cont_;
00885 ACE_Message_Block *tmp = 0;
00886
00887 do
00888 {
00889 tmp = mb;
00890 mb = mb->cont_;
00891 tmp->cont_ = 0;
00892
00893 ACE_Data_Block *db = tmp->data_block ();
00894 if (tmp->release_i (lock) != 0)
00895 {
00896 ACE_Allocator *allocator = db->data_block_allocator ();
00897 ACE_DES_FREE (db,
00898 allocator->free,
00899 ACE_Data_Block);
00900 }
00901 }
00902 while (mb);
00903
00904 this->cont_ = 0;
00905 }
00906
00907 int result = 0;
00908
00909 if (ACE_BIT_DISABLED (this->flags_,
00910 ACE_Message_Block::DONT_DELETE) &&
00911 this->data_block ())
00912 {
00913 if (this->data_block ()->release_no_delete (lock) == 0)
00914 result = 1;
00915 this->data_block_ = 0;
00916 }
00917
00918 // We will now commit suicide: this object *must* have come from the
00919 // allocator given.
00920 if (this->message_block_allocator_ == 0)
00921 delete this;
00922 else
00923 {
00924 ACE_Allocator *allocator = this->message_block_allocator_;
00925 ACE_DES_FREE (this,
00926 allocator->free,
00927 ACE_Message_Block);
00928 }
00929
00930 return result;
00931 }
|
|
|
Set a new data block pointer. A pointer to the original ACE_Data_Block is returned, and not released (as it is with ). Definition at line 391 of file Message_Block.inl. References ACE_TRACE, data_block_, rd_ptr(), and wr_ptr(). Referenced by ACE_InputCDR::ACE_InputCDR(), ACE_InputCDR::clone_from(), and ACE_InputCDR::exchange_data_blocks().
00392 {
00393 ACE_TRACE ("ACE_Message_Block::replace_data_block");
00394 ACE_Data_Block *old = this->data_block_;
00395 this->data_block_ = db;
00396
00397 if (db != 0)
00398 {
00399 // Set the read and write pointers in the <Message_Block> to point
00400 // to the buffer in the <ACE_Data_Block>.
00401 this->rd_ptr (this->data_block ()->base ());
00402 this->wr_ptr (this->data_block ()->base ());
00403 }
00404
00405 return old;
00406 }
|
|
|
Resets the Message Block data to contain nothing, i.e., sets the read and write pointers to align with the base. Definition at line 376 of file Message_Block.inl. References ACE_TRACE, rd_ptr_, and wr_ptr_. Referenced by ACE_InputCDR::clone_from(), and ACE_InputCDR::exchange_data_blocks().
|
|
||||||||||||||||
|
This method resets the allocators in all the message blocks in the chain. Definition at line 423 of file Message_Block.inl. References ACE_Data_Block::allocator_strategy_, cont(), data_block_, ACE_Data_Block::data_block_allocator_, and message_block_allocator_.
00426 {
00427 this->data_block_->allocator_strategy_ =
00428 allocator_strategy;
00429 this->data_block_->data_block_allocator_ =
00430 data_block_allocator;
00431 this->message_block_allocator_ =
00432 message_block_allocator;
00433
00434 if (this->cont () != 0)
00435 this->cont ()->reset_allocators (allocator_strategy,
00436 data_block_allocator,
00437 message_block_allocator);
00438 }
|
|
|
Get the current message flags.
Definition at line 33 of file Message_Block.inl. References ACE_TRACE. Referenced by ACE_InputCDR::exchange_data_blocks().
|
|
|
Bitwise-or the more_flags into the existing message flags and return the new value. Definition at line 105 of file Message_Block.inl. References ACE_TRACE, data_block(), Message_Flags, and ACE_Data_Block::set_flags().
00106 {
00107 ACE_TRACE ("ACE_Message_Block::set_flags");
00108 return this->data_block ()->set_flags (more_flags);
00109 }
|
|
|
Bitwise-or the into the existing message flags and return the new value. Definition at line 15 of file Message_Block.inl. References ACE_SET_BITS, ACE_TRACE, and Message_Flags. Referenced by ACE_InputCDR::exchange_data_blocks().
00016 {
00017 ACE_TRACE ("ACE_Message_Block::set_self_flags");
00018 // Later we might mask more_glags so that user can't change internal
00019 // ones: more_flags &= ~(USER_FLAGS -1).
00020 return ACE_SET_BITS (this->flags_, more_flags);
00021 }
|
|
|
Set the number of bytes in the top-level , reallocating space if necessary. However, the and remain at the original offsets into the buffer, even if it is reallocated. Returns 0 if successful, else -1. Definition at line 240 of file Message_Block.cpp. References ACE_TRACE, data_block(), and ACE_Data_Block::size().
00241 {
00242 ACE_TRACE ("ACE_Message_Block::size");
00243
00244 // Resize the underlying <ACE_Data_Block>.
00245 if (this->data_block ()->size (length) == -1)
00246 return -1;
00247
00248 return 0;
00249 }
|
|
|
Get the number of bytes in the top-level (i.e., does not consider the bytes in chained s). Definition at line 147 of file Message_Block.inl. References ACE_TRACE, data_block(), and ACE_Data_Block::size(). Referenced by ACE_InputCDR::clone_from(), ACE_CDR::consolidate(), ACE_InputCDR::exchange_data_blocks(), ACE_CDR::grow(), ACE_OutputCDR::grow_and_adjust(), total_size(), total_size_and_length(), and ACE_WIN32_Asynch_Write_File::writev().
00148 {
00149 ACE_TRACE ("ACE_Message_Block::size");
00150 return this->data_block ()->size ();
00151 }
|
|
|
Get the number of bytes available after the in the top-level . Definition at line 384 of file Message_Block.inl. References ACE_TRACE, mark(), and wr_ptr(). Referenced by ACE_WIN32_Asynch_Accept::accept(), ACE_POSIX_Asynch_Accept::accept(), ACE_InputCDR::ACE_InputCDR(), ACE_WIN32_Asynch_Read_Dgram_Result::complete(), ACE_WIN32_Asynch_Read_Stream_Result::complete(), copy(), ACE_WIN32_Asynch_Read_File::read(), ACE_WIN32_Asynch_Read_Stream::read(), ACE_POSIX_Asynch_Read_File::read(), ACE_POSIX_Asynch_Read_Stream::read(), ACE_WIN32_Asynch_Read_File::readv(), ACE_WIN32_Asynch_Read_Stream::readv(), ACE_WIN32_Asynch_Read_Dgram::recv(), and ACE_POSIX_Asynch_Read_Dgram::recv().
|
|
|
Get the number of allocated bytes in all , including chained s. Definition at line 295 of file Message_Block.cpp. References ACE_TRACE, capacity(), and cont().
00296 {
00297 ACE_TRACE ("ACE_Message_Block::total_capacity");
00298
00299 size_t size = 0;
00300
00301 for (const ACE_Message_Block *i = this;
00302 i != 0;
00303 i = i->cont ())
00304 size += i->capacity ();
00305
00306 return size;
00307 }
|
|
|
Get the length of the s, including chained s. Definition at line 281 of file Message_Block.cpp. References ACE_TRACE, cont(), and length(). Referenced by ACE_MEM_IO::send().
00282 {
00283 ACE_TRACE ("ACE_Message_Block::total_length");
00284
00285 size_t length = 0;
00286 for (const ACE_Message_Block *i = this;
00287 i != 0;
00288 i = i->cont ())
00289 length += i->length ();
00290
00291 return length;
00292 }
|
|
|
Get the total number of bytes in all s, including chained s. Definition at line 267 of file Message_Block.cpp. References ACE_TRACE, cont(), and size(). Referenced by ACE_Buffered_Svc_Handler<, >::put().
00268 {
00269 ACE_TRACE ("ACE_Message_Block::total_size");
00270
00271 size_t size = 0;
00272 for (const ACE_Message_Block *i = this;
00273 i != 0;
00274 i = i->cont ())
00275 size += i->size ();
00276
00277 return size;
00278 }
|
|
||||||||||||
|
|
Set the write pointer ahead bytes. This is used to compute the of a message. Definition at line 369 of file Message_Block.inl. References ACE_TRACE, and wr_ptr_.
|
|
|
Set the write pointer to ptr.
Definition at line 310 of file Message_Block.inl. References ACE_TRACE, base(), and wr_ptr_.
|
|
|
|
Definition at line 62 of file Message_Block.h. Referenced by init_i(). |
|
|
Declare the dynamic allocation hooks.
Definition at line 583 of file Message_Block.h. |
|
|
Pointer to next message block in the chain.
Definition at line 640 of file Message_Block.h. Referenced by clone(), cont(), duplicate(), init_i(), and release_i(). |
|
|
Pointer to the reference counted data structure that contains the actual memory buffer. Definition at line 653 of file Message_Block.h. Referenced by access_allocators(), data_block(), init_i(), release_i(), replace_data_block(), and reset_allocators(). |
|
|
Misc flags (e.g., DONT_DELETE and USER_FLAGS).
Definition at line 649 of file Message_Block.h. Referenced by ACE_Message_Block(). |
|
|
The allocator used to destroy ourselves when release is called and create new message blocks on duplicate. Definition at line 657 of file Message_Block.h. Referenced by access_allocators(), ACE_Message_Block(), clone(), duplicate(), init_i(), release_i(), and reset_allocators(). |
|
|
Pointer to next message in the list.
Definition at line 643 of file Message_Block.h. |
|
|
Pointer to previous message in the list.
Definition at line 646 of file Message_Block.h. |
|
|
Priority of message.
Definition at line 628 of file Message_Block.h. |
|
|
Pointer to beginning of next read.
Definition at line 622 of file Message_Block.h. Referenced by base(), crunch(), init_i(), length(), rd_ptr(), and reset(). |
|
|
Pointer to beginning of next write.
Definition at line 625 of file Message_Block.h. Referenced by ACE_Message_Block(), base(), crunch(), init_i(), length(), reset(), and wr_ptr(). |
1.3.6