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

Public Types | |
| typedef int | ACE_Message_Type |
| typedef u_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 Methods | |
| ACE_Message_Block (ACE_Allocator *message_block_allocator=0) | |
| Create an empty message. More... | |
| 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, u_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, u_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, u_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. More... | |
| void | msg_type (ACE_Message_Type type) |
| Set type of the message. More... | |
| int | is_data_msg (void) const |
| Find out what type of message this is. More... | |
| ACE_Message_Type | msg_class (void) const |
| Find out what class of message this is (there are two classes, <normal> messages and <high-priority> messages). More... | |
| Message_Flags | set_flags (Message_Flags more_flags) |
| Bitwise-or the <more_flags> into the existing message flags and return the new value. More... | |
| Message_Flags | clr_flags (Message_Flags less_flags) |
| Clear the message flag bits specified in <less_flags> and return the new value. More... | |
| Message_Flags | flags (void) const |
| Get the current message flags. More... | |
| Message_Flags | set_self_flags (ACE_Message_Block::Message_Flags more_flags) |
| Bitwise-or the <more_flags> into the existing message flags and return the new value. More... | |
| Message_Flags | clr_self_flags (ACE_Message_Block::Message_Flags less_flags) |
| Clear the message flag bits specified in <less_flags> and return the new value. More... | |
| Message_Flags | self_flags (void) const |
| Get the current message flags. More... | |
| u_long | msg_priority (void) const |
| Get priority of the message. More... | |
| void | msg_priority (u_long priority) |
| Set priority of the message. More... | |
| const ACE_Time_Value & | msg_execution_time (void) const |
| Get execution time associated with the message. More... | |
| void | msg_execution_time (const ACE_Time_Value &et) |
| Set execution time associated with the message. More... | |
| const ACE_Time_Value & | msg_deadline_time (void) const |
| Get absolute time of deadline associated with the message. More... | |
| void | msg_deadline_time (const ACE_Time_Value &dt) |
| Set absolute time of deadline associated with the message. More... | |
| virtual ACE_Message_Block * | clone (Message_Flags mask=0) const |
| Return an exact "deep copy" of the message, i.e., create fresh new copies of all the Data_Blocks and continuations. More... | |
| virtual ACE_Message_Block * | duplicate (void) const |
| Return a "shallow" copy that increments our reference count by 1. More... | |
| virtual ACE_Message_Block * | release (void) |
| int | copy (const char *buf, size_t n) |
| int | copy (const char *buf) |
| void | crunch (void) |
| Normalizes data in the top-level <Message_Block> to align with the base, i.e., it "shifts" the data pointed to by <rd_ptr> down to the <base> and then readjusts <rt_ptr> to point to <base> and <wr_ptr> to point to <base> + the length of the moved data. More... | |
| void | reset (void) |
| Resets the Message Block data to contain nothing, i.e., sets the read and write pointers to align with the base. More... | |
| void | access_allocators (ACE_Allocator *&allocator_strategy, ACE_Allocator *&data_block_allocator, ACE_Allocator *&message_block_allocator) |
| Access all the allocators in the message block. @todo: Not sure whether we would need finer control while trying to access allocators ie. a method for every allocator. More... | |
| void | reset_allocators (ACE_Allocator *allocator_strategy=0, ACE_Allocator *data_block_allocator=0, ACE_Allocator *message_block_allocator=0) |
| Reset all the allocators in the message block. @todo: Not sure whether we would need finer control while trying to reset allocators ie. a method for every allocator. More... | |
| char * | base (void) const |
| Get message data. More... | |
| void | base (char *data, size_t size, Message_Flags=DONT_DELETE) |
| Set message data (doesn't reallocate). More... | |
| char * | end (void) const |
| Return a pointer to 1 past the end of the allocated data in a message. More... | |
| char * | mark (void) const |
| char * | rd_ptr (void) const |
| Get the read pointer. More... | |
| void | rd_ptr (char *ptr) |
| Set the read pointer to <ptr>. More... | |
| void | rd_ptr (size_t n) |
| Set the read pointer ahead <n> bytes. More... | |
| char * | wr_ptr (void) const |
| Get the write pointer. More... | |
| void | wr_ptr (char *ptr) |
| Set the write pointer to <ptr>. More... | |
| void | wr_ptr (size_t n) |
| Set the write pointer ahead <n> bytes. This is used to compute the <length> of a message. More... | |
| ACE_Data_Block * | data_block (void) const |
| void | data_block (ACE_Data_Block *) |
| ACE_Data_Block * | replace_data_block (ACE_Data_Block *) |
| Set a new data block pointer. A pointer to the original <ACE_Data_Block> is returned, and not released (as it is with <data_block>). More... | |
| ACE_Message_Block * | cont (void) const |
| Get the continuation field. More... | |
| void | cont (ACE_Message_Block *) |
| Set the continuation field. More... | |
| ACE_Message_Block * | next (void) const |
| Get link to next message. More... | |
| void | next (ACE_Message_Block *) |
| Set link to next message. More... | |
| ACE_Message_Block * | prev (void) const |
| Get link to prev message. More... | |
| void | prev (ACE_Message_Block *) |
| Set link to prev message. More... | |
| ACE_Lock * | locking_strategy (void) |
| Get the locking strategy. More... | |
| ACE_Lock * | locking_strategy (ACE_Lock *) |
| Set a new locking strategy and return the hold one. More... | |
| int | reference_count (void) const |
| Get the current reference count. More... | |
| void | dump (void) const |
| Dump the state of an object. More... | |
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. More... | |
| void | length (size_t n) |
| Set the length of the message. More... | |
| size_t | total_length (void) const |
| Get the length of the <Message_Block>s, including chained <Message_Block>s. More... | |
| size_t | total_size (void) const |
| Get the total number of bytes in all <Message_Block>s, including chained <Message_Block>s. More... | |
| void | total_size_and_length (size_t &mb_size, size_t &mb_length) const |
| Get the total number of bytes and total length in all <Message_Block>s, including chained <Message_Block>s. More... | |
| size_t | size (void) const |
| Get the number of bytes in the top-level <Message_Block> (i.e., does not consider the bytes in chained <Message_Block>s). More... | |
| int | size (size_t length) |
| size_t | total_capacity (void) const |
| Get the number of allocated bytes in all <Message_Block>, including chained <Message_Block>s. More... | |
| size_t | capacity (void) const |
| Get the number of allocated bytes in the top-level <Message_Block>. More... | |
| size_t | space (void) const |
| Get the number of bytes available after the <wr_ptr_> in the top-level <Message_Block>. More... | |
Static Public Methods | |
| 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. More... | |
Protected Methods | |
| 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, u_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. More... | |
| int | release_i (ACE_Lock *lock) |
| Internal release implementation Returns 1 if the data block has to be destroyed. More... | |
| 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, u_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. More... | |
Protected Attributes | |
| size_t | rd_ptr_ |
| Pointer to beginning of next read. More... | |
| size_t | wr_ptr_ |
| Pointer to beginning of next write. More... | |
| u_long | priority_ |
| Priority of message. More... | |
| ACE_Message_Block * | cont_ |
| Pointer to next message block in the chain. More... | |
| ACE_Message_Block * | next_ |
| Pointer to next message in the list. More... | |
| ACE_Message_Block * | prev_ |
| Pointer to previous message in the list. More... | |
| ACE_Message_Block::Message_Flags | flags_ |
| Misc flags (e.g., DONT_DELETE and USER_FLAGS). More... | |
| ACE_Data_Block * | data_block_ |
| Pointer to the reference counted data structure that contains the actual memory buffer. More... | |
| ACE_Allocator * | message_block_allocator_ |
| The allocator used to destroy ourselves when release is called and create new message blocks on duplicate. More... | |
Private Methods | |
| 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>: 1. Contains a pointer to a reference-counted <ACE_Data_Block>, which in turn points to the actual data buffer. This allows very flexible and efficient sharing of data by multiple <ACE_Message_Block>s. 2. One or more <ACE_Message_Blocks> can be linked to form a ``fragment chain.'' 3. <ACE_Message_Blocks> can be linked together by <prev_> and <next_> pointers to form a queue of messages (e.g., this is how <ACE_Message_Queue> works).
Definition at line 54 of file Message_Block.h.
|
|
Definition at line 114 of file Message_Block.h. Referenced by ACE_Data_Block::ACE_Data_Block, ACE_Locked_Data_Block::ACE_Locked_Data_Block, clone, duplicate, is_data_msg, msg_type, and ACE_Data_Block::msg_type. |
|
|
|
Definition at line 59 of file Message_Block.h.
00060 {
00061 // = Data and proto
00062 /// Undifferentiated data message
00063 MB_DATA = 0x01,
00064 /// Undifferentiated protocol control
00065 MB_PROTO = 0x02,
00066
00067 // = Control messages
00068 /// Line break (regular and priority)
00069 MB_BREAK = 0x03,
00070 /// Pass file pointer
00071 MB_PASSFP = 0x04,
00072 /// Post an event to an event queue
00073 MB_EVENT = 0x05,
00074 /// Generate process signal
00075 MB_SIG = 0x06,
00076 /// ioctl; set/get params
00077 MB_IOCTL = 0x07,
00078 /// Set various stream head options
00079 MB_SETOPTS = 0x08,
00080
00081 // = Control messages
00082 /// Acknowledge ioctl (high priority; go to head of queue)
00083 MB_IOCACK = 0x81,
00084 /// Negative ioctl acknowledge
00085 MB_IOCNAK = 0x82,
00086 /// Priority proto message
00087 MB_PCPROTO = 0x83,
00088 /// Generate process signal
00089 MB_PCSIG = 0x84,
00090 /// Generate read notification
00091 MB_READ = 0x85,
00092 /// Flush your queues
00093 MB_FLUSH = 0x86,
00094 /// Stop transmission immediately
00095 MB_STOP = 0x87,
00096 /// Restart transmission after stop
00097 MB_START = 0x88,
00098 /// Line disconnect
00099 MB_HANGUP = 0x89,
00100 /// Fatal error used to set u.u_error
00101 MB_ERROR = 0x8a,
00102 /// Post an event to an event queue
00103 MB_PCEVENT = 0x8b,
00104
00105 // = Message class masks
00106 /// Normal priority message mask
00107 MB_NORMAL = 0x00,
00108 /// High priority control message mask
00109 MB_PRIORITY = 0x80,
00110 /// User-defined message mask
00111 MB_USER = 0x200
00112 };
|
|
|
Definition at line 117 of file Message_Block.h.
00118 {
00119 /// Don't delete the data on exit since we don't own it.
00120 DONT_DELETE = 01,
00121 /// user defined flags start here
00122 USER_FLAGS = 0x1000
00123 };
|
|
|
Create an empty message.
Definition at line 371 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, DONT_DELETE, init_i, LM_ERROR, ACE_Time_Value::max_time, MB_DATA, and ACE_Time_Value::zero. Referenced by clone, and duplicate.
00372 : flags_ (0), 00373 data_block_ (0) 00374 { 00375 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00376 00377 if (this->init_i (0, // size 00378 MB_DATA, // type 00379 0, // cont 00380 0, // data 00381 0, // allocator 00382 0, // locking strategy 00383 ACE_Message_Block::DONT_DELETE, // flags 00384 0, // 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 message_block_allocator) == -1) // message_block allocator 00390 ACE_ERROR ((LM_ERROR, 00391 ACE_LIB_TEXT ("ACE_Message_Block"))); 00392 } |
|
||||||||||||||||
|
Create an <ACE_Message_Block> that owns the <ACE_Data_Block> without copying it. If the <flags> is set to DONT_DELETE we don't delete the ACE_Data_Block. It is left to the client's responsibility to take care of the memory allocated for the data_block Definition at line 514 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, ACE_Data_Block::data_block_allocator, init_i, LM_ERROR, ACE_Time_Value::max_time, MB_NORMAL, Message_Flags, and ACE_Time_Value::zero.
00517 : flags_ (flags), 00518 data_block_ (0) 00519 { 00520 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00521 00522 if (this->init_i (0, // size 00523 MB_NORMAL, // type 00524 0, // cont 00525 0, // data 00526 0, // allocator 00527 0, // locking strategy 00528 0, // flags 00529 0, // priority 00530 ACE_Time_Value::zero, // execution time 00531 ACE_Time_Value::max_time, // absolute time of deadline 00532 data_block, // data block 00533 data_block->data_block_allocator (), 00534 message_block_allocator) == -1) 00535 ACE_ERROR ((LM_ERROR, 00536 ACE_LIB_TEXT ("ACE_Message_Block"))); 00537 } |
|
||||||||||||||||
|
Create a Message Block that assumes ownership of <data> without copying it (i.e., we don't delete it since we don't malloc it!). Note that the <size> of the <Message_Block> will be <size>, but the <length> will be 0 until <wr_ptr> is set. Definition at line 346 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, DONT_DELETE, init_i, LM_ERROR, ACE_Time_Value::max_time, MB_DATA, size, and ACE_Time_Value::zero.
00349 : flags_ (0), 00350 data_block_ (0) 00351 { 00352 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00353 00354 if (this->init_i (size, // size 00355 MB_DATA, // type 00356 0, // cont 00357 data, // data 00358 0, // allocator 00359 0, // locking strategy 00360 ACE_Message_Block::DONT_DELETE, // flags 00361 priority, // priority 00362 ACE_Time_Value::zero, // execution time 00363 ACE_Time_Value::max_time, // absolute time of deadline 00364 0, // data block 00365 0, // data_block allocator 00366 0) == -1) // message_block allocator 00367 ACE_ERROR ((LM_ERROR, 00368 ACE_LIB_TEXT ("ACE_Message_Block"))); 00369 } |
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Create an initialized message of type <type> containing <size> bytes. The <cont> argument initializes the continuation field in the <Message_Block>. If <data> == 0 then we create and own the <data>, using <allocator> 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 <size> of the <Message_Block> will be <size>, but the <length> will be 0 until <wr_ptr> 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. The <message_block_allocator> is used to allocate new <Message_Block> objects when a duplicate method is called. If a <message_block_allocator> is given, this <Message_Block> and future <Message_Block> objects created by duplicate will be free'ed into this allocator when they are released. Note: if you use this allocator, the <Message_Block> you created should have been created using this allocator because it will be released to the same allocator. Definition at line 394 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, DONT_DELETE, init_i, LM_ERROR, msg_type, and size.
00405 :flags_ (0), 00406 data_block_ (0) 00407 { 00408 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00409 00410 if (this->init_i (size, 00411 msg_type, 00412 msg_cont, 00413 msg_data, 00414 allocator_strategy, 00415 locking_strategy, 00416 msg_data ? ACE_Message_Block::DONT_DELETE : 0, 00417 priority, 00418 execution_time, 00419 deadline_time, 00420 0, // data block 00421 data_block_allocator, 00422 message_block_allocator) == -1) 00423 ACE_ERROR ((LM_ERROR, 00424 ACE_LIB_TEXT ("ACE_Message_Block"))); 00425 } |
|
||||||||||||
|
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 <mb> 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 539 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, ACE_Time_Value::max_time, MB_NORMAL, ACE_OS_String::memcpy, message_block_allocator_, rd_ptr, wr_ptr, wr_ptr_, and ACE_Time_Value::zero.
00541 :flags_ (0), 00542 data_block_ (0) 00543 { 00544 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00545 00546 if (ACE_BIT_DISABLED (mb.flags_, 00547 ACE_Message_Block::DONT_DELETE)) 00548 { 00549 if (this->init_i (0, // size 00550 MB_NORMAL, // type 00551 0, // cont 00552 0, // data 00553 0, // allocator 00554 0, // locking strategy 00555 0, // flags 00556 0, // priority 00557 ACE_Time_Value::zero, // execution time 00558 ACE_Time_Value::max_time, // absolute time of deadline 00559 mb.data_block ()->duplicate (), // data block 00560 mb.data_block ()->data_block_allocator (), 00561 mb.message_block_allocator_) == -1) 00562 ACE_ERROR ((LM_ERROR, 00563 ACE_LIB_TEXT ("ACE_Message_Block"))); 00564 00565 // Align ourselves 00566 char *start = ACE_ptr_align_binary (this->base (), 00567 align); 00568 // Set our rd & wr pointers 00569 this->rd_ptr (start); 00570 this->wr_ptr (start); 00571 00572 } 00573 else 00574 { 00575 if (this->init_i (0, // size 00576 MB_NORMAL, // type 00577 0, // cont 00578 0, // data 00579 0, // allocator 00580 0, // locking strategy 00581 0, // flags 00582 0, // priority 00583 ACE_Time_Value::zero, // execution time 00584 ACE_Time_Value::max_time, // absolute time of deadline 00585 mb.data_block ()->clone_nocopy (),// data block 00586 mb.data_block ()->data_block_allocator (), 00587 mb.message_block_allocator_) == -1) 00588 ACE_ERROR ((LM_ERROR, 00589 ACE_LIB_TEXT ("ACE_Message_Block"))); 00590 00591 // Align ourselves 00592 char *start = ACE_ptr_align_binary (this->base (), 00593 align); 00594 // Set our rd & wr pointers 00595 this->rd_ptr (start); 00596 this->wr_ptr (start); 00597 00598 // Get the alignment offset of the incoming ACE_Message_Block 00599 start = ACE_ptr_align_binary (mb.base (), 00600 align); 00601 00602 00603 // Actual offset for the incoming message block assuming that it 00604 // is also aligned to the same "align" byte 00605 size_t wr_offset = mb.wr_ptr_ - (start - mb.base ()); 00606 00607 // Copy wr_offset amount of data in to <this->data_block> 00608 (void) ACE_OS::memcpy (this->wr_ptr (), 00609 start, 00610 wr_offset); 00611 00612 // Dont move the write pointer, just leave it to the application 00613 // to do what it wants 00614 00615 } 00616 00617 00618 00619 00620 } |
|
|
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 910 of file Message_Block.cpp. References ACE_BIT_DISABLED, ACE_TRACE, data_block, DONT_DELETE, next_, prev_, and ACE_Data_Block::release.
00911 {
00912 ACE_TRACE ("ACE_Message_Block::~ACE_Message_Block");
00913
00914 if (ACE_BIT_DISABLED (this->flags_,
00915 ACE_Message_Block::DONT_DELETE)&&
00916 this->data_block ())
00917 this->data_block ()->release ();
00918
00919 this->prev_ = 0;
00920 this->next_ = 0;
00921 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Perform the actual initialization.
Definition at line 479 of file Message_Block.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, flags, init_i, LM_ERROR, msg_type, and size.
00492 : flags_ (0), 00493 data_block_ (0) 00494 { 00495 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00496 00497 if (this->init_i (size, 00498 msg_type, 00499 msg_cont, 00500 msg_data, 00501 allocator_strategy, 00502 locking_strategy, 00503 flags, 00504 priority, 00505 execution_time, 00506 deadline_time, 00507 db, 00508 data_block_allocator, 00509 message_block_allocator) == -1) 00510 ACE_ERROR ((LM_ERROR, 00511 ACE_LIB_TEXT ("ACE_Message_Block"))); 00512 } |
|
|
|
|
||||||||||||||||
|
Access all the allocators in the message block. @todo: Not sure whether we would need finer control while trying to access allocators ie. a method for every allocator. This method returns the allocators only from the first message block in the chain.
Definition at line 274 of file Message_Block.i. References ACE_Data_Block::allocator_strategy_, data_block_, ACE_Data_Block::data_block_allocator_, and message_block_allocator_.
00277 {
00278 allocator_strategy =
00279 this->data_block_->allocator_strategy_;
00280 data_block_allocator =
00281 this->data_block_->data_block_allocator_;
00282 message_block_allocator =
00283 this->message_block_allocator_;
00284 }
|
|
||||||||||||||||
|
Set message data (doesn't reallocate).
Definition at line 294 of file Message_Block.i. References ACE_TRACE, ACE_Data_Block::base, data_block, rd_ptr_, and wr_ptr_.
00297 {
00298 ACE_TRACE ("ACE_Message_Block::base");
00299 this->rd_ptr_ = 0;
00300 this->wr_ptr_ = 0;
00301 this->data_block ()->base (msg_data, msg_length, msg_flags);
00302 }
|
|
|
Get message data.
Definition at line 287 of file Message_Block.i. References ACE_TRACE, ACE_Data_Block::base, and data_block. Referenced by ACE_WIN32_Asynch_Accept::accept, ACE_POSIX_Asynch_Accept::accept, ACE_InputCDR::ACE_InputCDR, ACE_Message_Block, crunch, ACE_Activation_Queue::dequeue, ACE_Message_Queue_Ex::dequeue_deadline, ACE_Message_Queue_Ex::dequeue_head, ACE_Message_Queue_Ex::dequeue_prio, ACE_Message_Queue_Ex::dequeue_tail, ACE_InputCDR::exchange_data_blocks, ACE_WFMO_Reactor_Notify::handle_signal, ACE_CDR::mb_align, ACE_Future_Set::next_readable, ACE_WFMO_Reactor_Notify::notify, ACE_Message_Queue_Ex::peek_dequeue_head, ACE_WFMO_Reactor_Notify::purge_pending_notifications, rd_ptr, wr_ptr, and ACE_WIN32_Asynch_Write_File::writev.
00288 {
00289 ACE_TRACE ("ACE_Message_Block::base");
00290 return this->data_block ()->base ();
00291 }
|
|
|
Get the number of allocated bytes in the top-level <Message_Block>.
Definition at line 156 of file Message_Block.i. References ACE_TRACE, ACE_Data_Block::capacity, and data_block. Referenced by total_capacity.
00157 {
00158 ACE_TRACE ("ACE_Message_Block::capacity");
00159 return this->data_block ()->capacity ();
00160 }
|
|
|
Return an exact "deep copy" of the message, i.e., create fresh new copies of all the Data_Blocks and continuations.
Definition at line 1090 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_, rd_ptr, release, ACE_Data_Block::release, and wr_ptr. Referenced by ACE_InputCDR::steal_contents.
01091 {
01092 ACE_TRACE ("ACE_Message_Block::clone");
01093
01094 // Get a pointer to a "cloned" <ACE_Data_Block> (will copy the
01095 // values rather than increment the reference count).
01096 ACE_Data_Block *db = this->data_block ()->clone (mask);
01097
01098 if (db == 0)
01099 return 0;
01100
01101 ACE_Message_Block *nb;
01102
01103 if(message_block_allocator_ == 0)
01104 {
01105 ACE_NEW_RETURN (nb,
01106 ACE_Message_Block (0, // size
01107 ACE_Message_Type (0), // type
01108 0, // cont
01109 0, // data
01110 0, // allocator
01111 0, // locking strategy
01112 0, // flags
01113 this->priority_, // priority
01114 ACE_EXECUTION_TIME, // execution time
01115 ACE_DEADLINE_TIME, // absolute time to deadline
01116 // Get a pointer to a
01117 // "duplicated" <ACE_Data_Block>
01118 // (will simply increment the
01119 // reference count).
01120 db,
01121 db->data_block_allocator (),
01122 this->message_block_allocator_),
01123 0);
01124 }
01125 else
01126 {
01127 // This is the ACE_NEW_MALLOC macro with the return check removed.
01128 // We need to do it this way because if it fails we need to release
01129 // the cloned data block that was created above. If we used
01130 // ACE_NEW_MALLOC_RETURN, there would be a memory leak because the
01131 // above db pointer would be left dangling.
01132 nb = ACE_static_cast(ACE_Message_Block*,message_block_allocator_->malloc (sizeof (ACE_Message_Block)));
01133 if(nb != 0)
01134 new (nb) ACE_Message_Block (0, // size
01135 ACE_Message_Type (0), // type
01136 0, // cont
01137 0, // data
01138 0, // allocator
01139 0, // locking strategy
01140 0, // flags
01141 this->priority_, // priority
01142 ACE_EXECUTION_TIME, // execution time
01143 ACE_DEADLINE_TIME, // absolute time to deadline
01144 db,
01145 db->data_block_allocator (),
01146 this->message_block_allocator_);
01147 }
01148
01149 if (nb == 0)
01150 {
01151 db->release ();
01152 return 0;
01153 }
01154
01155 // Set the read and write pointers in the new <Message_Block> to the
01156 // same relative offset as in the existing <Message_Block>.
01157 nb->rd_ptr (this->rd_ptr_);
01158 nb->wr_ptr (this->wr_ptr_);
01159
01160 // Clone all the continuation messages if necessary.
01161 if (this->cont () != 0
01162 && (nb->cont_ = this->cont ()->clone (mask)) == 0)
01163 {
01164 nb->release ();
01165 return 0;
01166 }
01167 return nb;
01168 }
|
|
|
Clear the message flag bits specified in <less_flags> and return the new value.
Definition at line 114 of file Message_Block.i. References ACE_TRACE, ACE_Data_Block::clr_flags, data_block, and Message_Flags.
00115 {
00116 ACE_TRACE ("ACE_Message_Block::clr_flags");
00117 return this->data_block ()->clr_flags (less_flags);
00118 }
|
|
|
Clear the message flag bits specified in <less_flags> and return the new value.
Definition at line 23 of file Message_Block.i. 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.
00024 {
00025 ACE_TRACE ("ACE_Message_Block::clr_self_flags");
00026 // Later we might mask more_flags so that user can't change internal
00027 // ones: less_flags &= ~(USER_FLAGS -1).
00028 return ACE_CLR_BITS (this->flags_, less_flags);
00029 }
|
|
|
Set the continuation field.
Definition at line 411 of file Message_Block.i. 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 97 of file Message_Block.cpp. References ACE_TRACE, ACE_OS_String::memcpy, space, ACE_OS_String::strlen, and wr_ptr.
00098 {
00099 ACE_TRACE ("ACE_Message_Block::copy");
00100
00101 /* size_t len = ACE_static_cast(size_t,
00102 (this->end () - this->wr_ptr ())); */
00103 // Note that for this to work correct, end() *must* be >= wr_ptr().
00104 size_t len = this->space ();
00105
00106 size_t buflen = ACE_OS::strlen (buf) + 1;
00107
00108 if (len < buflen)
00109 return -1;
00110 else
00111 {
00112 (void) ACE_OS::memcpy (this->wr_ptr (),
00113 buf,
00114 buflen);
00115 this->wr_ptr (buflen);
00116 return 0;
00117 }
00118 }
|
|
||||||||||||
|
Copies data into this ACE_Message_Block. Data is copied into the block starting at the current write pointer.
Definition at line 75 of file Message_Block.cpp. References ACE_TRACE, ACE_OS_String::memcpy, space, and wr_ptr. Referenced by ACE_InputCDR::ACE_InputCDR, ACE_CDR::consolidate, ACE_CDR::grow, and ACE_UPIPE_Stream::send.
00076 {
00077 ACE_TRACE ("ACE_Message_Block::copy");
00078
00079 /*size_t len = ACE_static_cast(size_t,
00080 this->end () - this->wr_ptr ());*/
00081 // Note that for this to work correct, end () *must* be >= mark ().
00082 size_t len = this->space ();
00083
00084 if (len < n)
00085 return -1;
00086 else
00087 {
00088 (void) ACE_OS::memcpy (this->wr_ptr (),
00089 buf,
00090 n);
00091 this->wr_ptr (n);
00092 return 0;
00093 }
00094 }
|
|
|
Normalizes data in the top-level <Message_Block> to align with the base, i.e., it "shifts" the data pointed to by <rd_ptr> down to the <base> and then readjusts <rt_ptr> to point to <base> and <wr_ptr> to point to <base> + the length of the moved data.
Definition at line 121 of file Message_Block.cpp. References base, length, ACE_OS_String::memmove, rd_ptr, and wr_ptr.
|
|
|
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 <replace_data_block> 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 58 of file Message_Block.cpp. References ACE_BIT_DISABLED, ACE_TRACE, data_block_, DONT_DELETE, rd_ptr, ACE_Data_Block::release, and wr_ptr.
00059 {
00060 ACE_TRACE ("ACE_Message_Block::data_block");
00061 if (ACE_BIT_DISABLED (this->flags_,
00062 ACE_Message_Block::DONT_DELETE)
00063 && this->data_block_ != 0)
00064 this->data_block_->release ();
00065
00066 this->data_block_ = db;
00067
00068 // Set the read and write pointers in the <Message_Block> to point
00069 // to the buffer in the <ACE_Data_Block>.
00070 this->rd_ptr (this->data_block ()->base ());
00071 this->wr_ptr (this->data_block ()->base ());
00072 }
|
|
|
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 7 of file Message_Block.i. 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.
00008 {
00009 ACE_TRACE ("ACE_Message_Block::data_block");
00010 return this->data_block_;
00011 }
|
|
|
Dump the state of an object.
Definition at line 161 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.
00162 {
00163 ACE_TRACE ("ACE_Message_Block::dump");
00164 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00165 ACE_DEBUG ((LM_DEBUG,
00166 ACE_LIB_TEXT ("-----( Message Block )-----\n")
00167 ACE_LIB_TEXT ("priority_ = %d\n")
00168 ACE_LIB_TEXT ("next_ = %u\n")
00169 ACE_LIB_TEXT ("prev_ = %u\n")
00170 ACE_LIB_TEXT ("cont_ = %u\n")
00171 ACE_LIB_TEXT ("rd_ptr_ = %u\n")
00172 ACE_LIB_TEXT ("wr_ptr_ = %u\n")
00173 ACE_LIB_TEXT ("---------------------------\n"),
00174 this->priority_,
00175 this->next_,
00176 this->prev_,
00177 this->cont_,
00178 this->rd_ptr_,
00179 this->wr_ptr_));
00180 this->data_block ()->dump ();
00181 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00182 }
|
|
|
Return a "shallow" copy that increments our reference count by 1. This is similar to CORBA's <_duplicate> method, which is useful if you want to eliminate lots of checks for NULL <mb> pointers before calling <_duplicate> on them. Definition at line 1030 of file Message_Block.cpp. References ACE_TRACE, and duplicate.
|
|
|
Return a "shallow" copy that increments our reference count by 1.
Definition at line 951 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.
00952 {
00953 ACE_TRACE ("ACE_Message_Block::duplicate");
00954
00955 ACE_Message_Block *nb;
00956
00957 // Create a new <ACE_Message_Block> that contains unique copies of
00958 // the message block fields, but a reference counted duplicate of
00959 // the <ACE_Data_Block>.
00960
00961 // If there is no allocator, use the standard new and delete calls.
00962 if (this->message_block_allocator_ == 0)
00963 ACE_NEW_RETURN (nb,
00964 ACE_Message_Block (0, // size
00965 ACE_Message_Type (0), // type
00966 0, // cont
00967 0, // data
00968 0, // allocator
00969 0, // locking strategy
00970 0, // flags
00971 this->priority_, // priority
00972 ACE_EXECUTION_TIME,
00973 ACE_DEADLINE_TIME,
00974 // Get a pointer to a
00975 // "duplicated" <ACE_Data_Block>
00976 // (will simply increment the
00977 // reference count).
00978 this->data_block ()->duplicate (),
00979 this->data_block ()->data_block_allocator (),
00980 this->message_block_allocator_),
00981 0);
00982 else // Otherwise, use the message_block_allocator passed in.
00983 ACE_NEW_MALLOC_RETURN (nb,
00984 ACE_static_cast(ACE_Message_Block*,
00985 message_block_allocator_->malloc (sizeof (ACE_Message_Block))),
00986 ACE_Message_Block (0, // size
00987 ACE_Message_Type (0), // type
00988 0, // cont
00989 0, // data
00990 0, // allocator
00991 0, // locking strategy
00992 0, // flags
00993 this->priority_, // priority
00994 ACE_EXECUTION_TIME,
00995 ACE_DEADLINE_TIME,
00996 // Get a pointer to a
00997 // "duplicated" <ACE_Data_Block>
00998 // (will simply increment the
00999 // reference count).
01000 this->data_block ()->duplicate (),
01001 this->data_block ()->data_block_allocator (),
01002 this->message_block_allocator_),
01003 0);
01004
01005 // Set the read and write pointers in the new <Message_Block> to the
01006 // same relative offset as in the existing <Message_Block>. Note
01007 // that we are assuming that the data_block()->base() pointer
01008 // doesn't change when it's duplicated.
01009 nb->rd_ptr (this->rd_ptr_);
01010 nb->wr_ptr (this->wr_ptr_);
01011
01012 // Increment the reference counts of all the continuation messages.
01013 if (this->cont_)
01014 {
01015 nb->cont_ = this->cont_->duplicate ();
01016
01017 // If things go wrong, release all of our resources and return
01018 // 0.
01019 if (nb->cont_ == 0)
01020 {
01021 nb->release ();
01022 nb = 0;
01023 }
01024 }
01025
01026 return nb;
01027 }
|
|
|
Return a pointer to 1 past the end of the allocated data in a message.
Definition at line 342 of file Message_Block.i. 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.
00343 {
00344 ACE_TRACE ("ACE_Message_Block::end");
00345 return this->data_block ()->end ();
00346 }
|
|
|
Get the current message flags.
Definition at line 121 of file Message_Block.i. References ACE_TRACE, data_block, and ACE_Data_Block::flags. Referenced by ACE_Message_Block, init_i, and ACE_OutputCDR::write_octet_array_mb.
00122 {
00123 ACE_TRACE ("ACE_Message_Block::flags");
00124 return this->data_block ()->flags ();
00125 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Create an initialized message of type <type> containing <size> bytes. The <cont> argument initializes the continuation field in the <Message_Block>. If <data> == 0 then we create and own the <data>, using <allocator> 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 <size> of the <Message_Block> will be <size>, but the <length> will be 0 until <wr_ptr> 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 428 of file Message_Block.cpp. References ACE_TRACE, DONT_DELETE, init_i, msg_type, and size.
00439 {
00440 ACE_TRACE ("ACE_Message_Block::init");
00441
00442 return this->init_i (size,
00443 msg_type,
00444 msg_cont,
00445 msg_data,
00446 allocator_strategy,
00447 locking_strategy,
00448 msg_data ? ACE_Message_Block::DONT_DELETE : 0,
00449 priority,
00450 execution_time,
00451 deadline_time,
00452 0, // data block
00453 data_block_allocator,
00454 message_block_allocator);
00455 }
|
|
||||||||||||
|
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 <size> of the <Message_Block> will be <size>, but the <length> will be 0 until <wr_ptr> is set. Definition at line 458 of file Message_Block.cpp. References ACE_TRACE, DONT_DELETE, init_i, ACE_Time_Value::max_time, MB_DATA, size, and ACE_Time_Value::zero.
00460 {
00461 ACE_TRACE ("ACE_Message_Block::init");
00462 // Should we also initialize all the other fields, as well?
00463
00464 return this->init_i (size, // size
00465 MB_DATA, // type
00466 0, // cont
00467 data, // data
00468 0, // allocator
00469 0, // locking strategy
00470 ACE_Message_Block::DONT_DELETE, // flags
00471 0, // priority
00472 ACE_Time_Value::zero, // execution time
00473 ACE_Time_Value::max_time, // absolute time of deadline
00474 0, // data block
00475 0, // data_block allocator
00476 0); // message_block allocator
00477 }
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Perform the actual initialization.
Definition at line 623 of file Message_Block.cpp. References ACE_ALLOCATOR_RETURN, ACE_Data_Block, ACE_FUNCTION_TIMEPROBE, ACE_NEW_MALLOC_RETURN, ACE_TIMEPROBE, ACE_TRACE, cont_, data_block, data_block_, flags, ACE_Allocator::instance, ACE_Allocator::malloc, message_block_allocator_, msg_type, next_, prev_, priority_, rd_ptr_, ACE_Data_Block::release, ACE_Data_Block::size, size, and wr_ptr_. Referenced by ACE_Message_Block, and init.
00636 {
00637 ACE_TRACE ("ACE_Message_Block::init_i");
00638 ACE_FUNCTION_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_ENTER);
00639
00640 this->rd_ptr_ = 0;
00641 this->wr_ptr_ = 0;
00642 this->priority_ = priority;
00643 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00644 this->execution_time_ = execution_time;
00645 this->deadline_time_ = deadline_time;
00646 #else
00647 ACE_UNUSED_ARG (execution_time);
00648 ACE_UNUSED_ARG (deadline_time);
00649 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00650 this->cont_ = msg_cont;
00651 this->next_ = 0;
00652 this->prev_ = 0;
00653
00654 this->message_block_allocator_ = message_block_allocator;
00655
00656 if (this->data_block_ != 0)
00657 {
00658 this->data_block_->release ();
00659 this->data_block_ = 0;
00660 }
00661
00662 if (db == 0)
00663 {
00664 if (data_block_allocator == 0)
00665 ACE_ALLOCATOR_RETURN (data_block_allocator,
00666 ACE_Allocator::instance (),
00667 -1);
00668
00669 ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_ALLOC);
00670
00671 // Allocate the <ACE_Data_Block> portion, which is reference
00672 // counted.
00673 ACE_NEW_MALLOC_RETURN (db,
00674 ACE_static_cast(ACE_Data_Block *,
00675 data_block_allocator->malloc (sizeof (ACE_Data_Block))),
00676 ACE_Data_Block (size,
00677 msg_type,
00678 msg_data,
00679 allocator_strategy,
00680 locking_strategy,
00681 flags,
00682 data_block_allocator),
00683 -1);
00684 ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_CTOR);
00685 }
00686
00687 // Reset the data_block_ pointer.
00688 this->data_block (db);
00689 // If the data alloc failed, the ACE_Data_Block ctor can't relay
00690 // that directly. Therefore, need to check it explicitly.
00691 if (db->size () < size)
00692 return -1;
00693 return 0;
00694 }
|
|
|
Find out what type of message this is.
Definition at line 204 of file Message_Block.i. References ACE_Message_Type, ACE_TRACE, MB_DATA, MB_PCPROTO, MB_PROTO, and msg_type.
00205 {
00206 ACE_TRACE ("ACE_Message_Block::is_data_msg");
00207 ACE_Message_Type mt = this->msg_type ();
00208 return
00209 mt == ACE_Message_Block::MB_DATA
00210 || mt == ACE_Message_Block::MB_PROTO
00211 || mt == ACE_Message_Block::MB_PCPROTO;
00212 }
|
|
|
Set the length of the message.
Definition at line 140 of file Message_Block.i. References ACE_TRACE, rd_ptr_, and wr_ptr_.
|
|
|
|
Set a new locking strategy and return the hold one.
Definition at line 502 of file Message_Block.i. References ACE_TRACE, data_block, and ACE_Data_Block::locking_strategy.
00503 {
00504 ACE_TRACE ("ACE_Message_Block::locking_strategy");
00505 ACE_Lock *ols = this->data_block ()->locking_strategy ();
00506 this->data_block ()->locking_strategy (nls);
00507 return ols;
00508 }
|
|
|
Get the locking strategy.
Definition at line 495 of file Message_Block.i. References ACE_TRACE, data_block, and ACE_Data_Block::locking_strategy.
00496 {
00497 ACE_TRACE ("ACE_Message_Block::locking_strategy");
00498 return this->data_block ()->locking_strategy ();
00499 }
|
|
|
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 328 of file Message_Block.i. References ACE_TRACE, data_block, and ACE_Data_Block::mark. Referenced by space.
00329 {
00330 ACE_TRACE ("ACE_Message_Block::mark");
00331 return this->data_block ()->mark ();
00332 }
|
|
|
Find out what class of message this is (there are two classes, <normal> messages and <high-priority> messages).
Definition at line 191 of file Message_Block.i. References ACE_TRACE, MB_NORMAL, MB_PRIORITY, MB_USER, and msg_type.
00192 {
00193 ACE_TRACE ("ACE_Message_Block::msg_class");
00194
00195 if (this->msg_type () < ACE_Message_Block::MB_PRIORITY)
00196 return ACE_Message_Block::MB_NORMAL;
00197 else if (this->msg_type () < ACE_Message_Block::MB_USER)
00198 return ACE_Message_Block::MB_PRIORITY;
00199 else
00200 return ACE_Message_Block::MB_USER;
00201 }
|
|
|
Set absolute time of deadline associated with the message.
Definition at line 263 of file Message_Block.i. References ACE_TRACE.
00264 {
00265 ACE_TRACE ("ACE_Message_Block::msg_deadline_time (const ACE_Time_Value & et)");
00266 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00267 this->deadline_time_ = dt;
00268 #else
00269 ACE_UNUSED_ARG (dt);
00270 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00271 }
|
|
|
Get absolute time of deadline associated with the message.
Definition at line 251 of file Message_Block.i. References ACE_TRACE, and ACE_Time_Value::max_time. 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.
00252 {
00253 ACE_TRACE ("ACE_Message_Block::msg_deadline_time (void)");
00254
00255 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00256 return this->deadline_time_;
00257 #else
00258 return ACE_Time_Value::max_time; // absolute time of deadline
00259 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00260 }
|
|
|
Set execution time associated with the message.
Definition at line 240 of file Message_Block.i. References ACE_TRACE.
00241 {
00242 ACE_TRACE ("ACE_Message_Block::msg_execution_time (const ACE_Time_Value & et)");
00243 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00244 this->execution_time_ = et;
00245 #else
00246 ACE_UNUSED_ARG (et);
00247 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00248 }
|
|
|
Get execution time associated with the message.
Definition at line 229 of file Message_Block.i. References ACE_TRACE, and ACE_Time_Value::zero. Referenced by ACE_Laxity_Message_Strategy::convert_priority.
00230 {
00231 ACE_TRACE ("ACE_Message_Block::msg_execution_time (void)");
00232 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
00233 return this->execution_time_;
00234 #else
00235 return ACE_Time_Value::zero;
00236 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
00237 }
|
|
|
Set priority of the message.
Definition at line 222 of file Message_Block.i. References ACE_TRACE, and priority_.
|
|
|
Get priority of the message.
Definition at line 215 of file Message_Block.i. References ACE_TRACE, and priority_. 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 184 of file Message_Block.i. References ACE_Message_Type, ACE_TRACE, data_block, and ACE_Data_Block::msg_type.
00185 {
00186 ACE_TRACE ("ACE_Message_Block::msg_type");
00187 this->data_block ()->msg_type (t);
00188 }
|
|
|
Get type of the message.
Definition at line 177 of file Message_Block.i. References ACE_TRACE, data_block, and ACE_Data_Block::msg_type. Referenced by ACE_Message_Block, ACE_Stream_Tail::control, init, init_i, is_data_msg, msg_class, ACE_Stream_Tail::put, and ACE_Stream_Head::put.
00178 {
00179 ACE_TRACE ("ACE_Message_Block::msg_type");
00180 return this->data_block ()->msg_type ();
00181 }
|
|
|
Set link to next message.
Definition at line 443 of file Message_Block.i. References ACE_TRACE, and next_.
|
|
|
|
Definition at line 1172 of file Message_Block.cpp. References ACE_TRACE.
01173 {
01174 ACE_TRACE ("ACE_Message_Block::operator=");
01175 return *this;
01176 }
|
|
|
Set link to prev message.
Definition at line 457 of file Message_Block.i. References ACE_TRACE, and prev_.
|
|
|
|
Set the read pointer ahead <n> bytes.
Definition at line 357 of file Message_Block.i. References ACE_TRACE, and rd_ptr_.
|
|
|
Set the read pointer to <ptr>.
Definition at line 350 of file Message_Block.i. References ACE_TRACE, base, and rd_ptr_.
|
|
|
|
Get the current reference count.
Definition at line 48 of file Message_Block.i. References data_block, and ACE_Data_Block::reference_count.
00049 {
00050 return data_block () ? data_block ()->reference_count () : 0;
00051 }
|
|
|
This behaves like the non-static method <release>, except that it checks if <mb> is 0. This is similar to <CORBA::release>, which is useful if you want to eliminate lots of checks for NULL pointers before calling <release> on them. Returns <mb>. Definition at line 900 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 793 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::accept, ACE_Stream_Tail::canonical_flush, ACE_Stream_Head::canonical_flush, clone, ACE_Stream::control, ACE_Activation_Queue::dequeue, ACE_Message_Queue_Ex::dequeue_deadline, ACE_Message_Queue_Ex::dequeue_head, ACE_Message_Queue_Ex::dequeue_prio, ACE_Message_Queue_Ex::dequeue_tail, duplicate, ACE_Message_Queue_Ex::enqueue_deadline, ACE_Message_Queue_Ex::enqueue_head, ACE_Message_Queue_Ex::enqueue_prio, ACE_Message_Queue_Ex::enqueue_tail, ACE_Message_Queue< ACE_SYNCH_USE >::flush_i, ACE_Asynch_Acceptor::handle_accept, ACE_WFMO_Reactor_Notify::handle_signal, ACE_Future_Set::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.
00794 {
00795 ACE_TRACE ("ACE_Message_Block::release");
00796
00797 // We want to hold the data block in a temporary variable because we
00798 // invoked "delete this;" at some point, so using this->data_block_
00799 // could be a bad idea.
00800 ACE_Data_Block *tmp = this->data_block ();
00801
00802 // This flag is set to 1 when we have to destroy the data_block
00803 int destroy_dblock = 0;
00804
00805 ACE_Lock *lock = 0;
00806
00807 // Do we have a valid data block
00808 if (this->data_block ())
00809 {
00810 // Grab the lock that belongs to my data block
00811 lock = this->data_block ()->locking_strategy ();
00812
00813 // if we have a lock
00814 if (lock != 0)
00815 {
00816 // One guard for all
00817 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock, 0);
00818
00819 // Call non-guarded release with <lock>
00820 destroy_dblock = this->release_i (lock);
00821 }
00822 // This is the case when we have a valid data block but no lock
00823 else
00824 // Call non-guarded release with no lock
00825 destroy_dblock = this->release_i (0);
00826 }
00827 else
00828 // This is the case when we don't even have a valid data block
00829 destroy_dblock = this->release_i (0);
00830
00831 if (destroy_dblock != 0)
00832 {
00833 ACE_Allocator *allocator = tmp->data_block_allocator ();
00834 ACE_DES_FREE (tmp,
00835 allocator->free,
00836 ACE_Data_Block);
00837 }
00838
00839 return 0;
00840 }
|
|
|
Internal release implementation Returns 1 if the data block has to be destroyed.
Definition at line 843 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.
00844 {
00845 ACE_TRACE ("ACE_Message_Block::release_i");
00846
00847 // Free up all the continuation messages.
00848 if (this->cont_)
00849 {
00850 ACE_Message_Block *mb = this->cont_;
00851 ACE_Message_Block *tmp;
00852
00853 do
00854 {
00855 tmp = mb;
00856 mb = mb->cont_;
00857 tmp->cont_ = 0;
00858
00859 ACE_Data_Block *db = tmp->data_block ();
00860 if (tmp->release_i (lock) != 0)
00861 {
00862 ACE_Allocator *allocator = db->data_block_allocator ();
00863 ACE_DES_FREE (db,
00864 allocator->free,
00865 ACE_Data_Block);
00866 }
00867 }
00868 while (mb);
00869
00870 this->cont_ = 0;
00871 }
00872
00873 int result = 0;
00874
00875 if (ACE_BIT_DISABLED (this->flags_,
00876 ACE_Message_Block::DONT_DELETE) &&
00877 this->data_block ())
00878 {
00879 if (this->data_block ()->release_no_delete (lock) == 0)
00880 result = 1;
00881 this->data_block_ = 0;
00882 }
00883
00884 // We will now commit suicide: this object *must* have come from the
00885 // allocator given.
00886 if (this->message_block_allocator_ == 0)
00887 delete this;
00888 else
00889 {
00890 ACE_Allocator *allocator = this->message_block_allocator_;
00891 ACE_DES_FREE (this,
00892 allocator->free,
00893 ACE_Message_Block);
00894 }
00895
00896 return result;
00897 }
|
|
|
Set a new data block pointer. A pointer to the original <ACE_Data_Block> is returned, and not released (as it is with <data_block>).
Definition at line 393 of file Message_Block.i. References ACE_TRACE, data_block_, rd_ptr, and wr_ptr. Referenced by ACE_InputCDR::clone_from, and ACE_InputCDR::exchange_data_blocks.
00394 {
00395 ACE_TRACE ("ACE_Message_Block::replace_data_block");
00396 ACE_Data_Block *old = this->data_block_;
00397 this->data_block_ = db;
00398
00399 if (db != 0)
00400 {
00401 // Set the read and write pointers in the <Message_Block> to point
00402 // to the buffer in the <ACE_Data_Block>.
00403 this->rd_ptr (this->data_block ()->base ());
00404 this->wr_ptr (this->data_block ()->base ());
00405 }
00406
00407 return old;
00408 }
|
|
|
Resets the Message Block data to contain nothing, i.e., sets the read and write pointers to align with the base.
Definition at line 378 of file Message_Block.i. References ACE_TRACE, rd_ptr_, and wr_ptr_. Referenced by ACE_InputCDR::clone_from, and ACE_InputCDR::exchange_data_blocks.
|
|
||||||||||||||||
|
Reset all the allocators in the message block. @todo: Not sure whether we would need finer control while trying to reset allocators ie. a method for every allocator. This method resets the allocators in all the message blocks in the chain. Definition at line 425 of file Message_Block.i. References ACE_Data_Block::allocator_strategy_, cont, data_block_, ACE_Data_Block::data_block_allocator_, and message_block_allocator_.
00428 {
00429 this->data_block_->allocator_strategy_ =
00430 allocator_strategy;
00431 this->data_block_->data_block_allocator_ =
00432 data_block_allocator;
00433 this->message_block_allocator_ =
00434 message_block_allocator;
00435
00436 if (this->cont () != 0)
00437 this->cont ()->reset_allocators (allocator_strategy,
00438 data_block_allocator,
00439 message_block_allocator);
00440 }
|
|
|
Get the current message flags.
Definition at line 32 of file Message_Block.i. References ACE_TRACE, and flags_. 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 107 of file Message_Block.i. References ACE_TRACE, data_block, Message_Flags, and ACE_Data_Block::set_flags.
00108 {
00109 ACE_TRACE ("ACE_Message_Block::set_flags");
00110 return this->data_block ()->set_flags (more_flags);
00111 }
|
|
|
Bitwise-or the <more_flags> into the existing message flags and return the new value.
Definition at line 14 of file Message_Block.i. References ACE_SET_BITS, ACE_TRACE, and Message_Flags. Referenced by ACE_InputCDR::exchange_data_blocks.
00015 {
00016 ACE_TRACE ("ACE_Message_Block::set_self_flags");
00017 // Later we might mask more_glags so that user can't change internal
00018 // ones: more_flags &= ~(USER_FLAGS -1).
00019 return ACE_SET_BITS (this->flags_, more_flags);
00020 }
|
|
|
Set the number of bytes in the top-level <Message_Block>, reallocating space if necessary. However, the <rd_ptr_> and <wr_ptr_> remain at the original offsets into the buffer, even if it is reallocated. Returns 0 if successful, else -1. Definition at line 217 of file Message_Block.cpp. References ACE_TRACE, data_block, length, and ACE_Data_Block::size.
00218 {
00219 ACE_TRACE ("ACE_Message_Block::size");
00220
00221 // Resize the underlying <ACE_Data_Block>.
00222 if (this->data_block ()->size (length) == -1)
00223 return -1;
00224
00225 return 0;
00226 }
|
|
|
Get the number of bytes in the top-level <Message_Block> (i.e., does not consider the bytes in chained <Message_Block>s).
Definition at line 149 of file Message_Block.i. References ACE_TRACE, data_block, and ACE_Data_Block::size. Referenced by ACE_WIN32_Asynch_Accept::accept, ACE_POSIX_Asynch_Accept::accept, ACE_Message_Block, ACE_CDR::consolidate, ACE_InputCDR::exchange_data_blocks, ACE_CDR::grow, ACE_OutputCDR::grow_and_adjust, init, init_i, total_capacity, total_size, total_size_and_length, and ACE_WIN32_Asynch_Write_File::writev.
00150 {
00151 ACE_TRACE ("ACE_Message_Block::size");
00152 return this->data_block ()->size ();
00153 }
|
|
|
Get the number of bytes available after the <wr_ptr_> in the top-level <Message_Block>.
Definition at line 386 of file Message_Block.i. References ACE_TRACE, mark, and wr_ptr. Referenced by 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, and ACE_WIN32_Asynch_Read_Dgram::recv.
|
|
|
Get the number of allocated bytes in all <Message_Block>, including chained <Message_Block>s.
Definition at line 272 of file Message_Block.cpp. References ACE_TRACE, capacity, cont, and size.
|
|
|
Get the length of the <Message_Block>s, including chained <Message_Block>s.
Definition at line 258 of file Message_Block.cpp. References ACE_TRACE, cont, and length. Referenced by ACE_MEM_IO::send.
|
|
|
Get the total number of bytes in all <Message_Block>s, including chained <Message_Block>s.
Definition at line 244 of file Message_Block.cpp. References ACE_TRACE, cont, and size. Referenced by ACE_Buffered_Svc_Handler::put.
|
|
||||||||||||
|
|
Set the write pointer ahead <n> bytes. This is used to compute the <length> of a message.
Definition at line 371 of file Message_Block.i. References ACE_TRACE, and wr_ptr_.
|
|
|
Set the write pointer to <ptr>.
Definition at line 312 of file Message_Block.i. References ACE_TRACE, base, and wr_ptr_.
|
|
|
|
Definition at line 57 of file Message_Block.h. Referenced by init_i. |
|
|
Declare the dynamic allocation hooks.
Definition at line 576 of file Message_Block.h. |
|
|
Pointer to next message block in the chain.
Definition at line 633 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 646 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 642 of file Message_Block.h. Referenced by ACE_Message_Block, and self_flags. |
|
|
The allocator used to destroy ourselves when release is called and create new message blocks on duplicate.
Definition at line 650 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 636 of file Message_Block.h. Referenced by init_i, next, and ~ACE_Message_Block. |
|
|
Pointer to previous message in the list.
Definition at line 639 of file Message_Block.h. Referenced by init_i, prev, and ~ACE_Message_Block. |
|
|
Priority of message.
Definition at line 621 of file Message_Block.h. Referenced by init_i, and msg_priority. |
|
|
Pointer to beginning of next read.
Definition at line 615 of file Message_Block.h. |
|
|
Pointer to beginning of next write.
Definition at line 618 of file Message_Block.h. Referenced by ACE_Message_Block, base, init_i, length, reset, and wr_ptr. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002