Stores messages for use throughout ACE (particularly in an ACE_Message_Queue). More...
#include <Message_Block.h>

Public Types | |
| 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 } |
| typedef int | ACE_Message_Type |
| typedef unsigned long | Message_Flags |
Public Member Functions | |
| ACE_Message_Block (ACE_Allocator *message_block_allocator=0) | |
| Create an empty message. | |
| ACE_Message_Block (ACE_Data_Block *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 | |
| 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 Message_Block. | |
| size_t | space (void) const |
Static Public Member Functions | |
| static ACE_Message_Block * | duplicate (const ACE_Message_Block *mb) |
| static 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_Time_Value | execution_time_ |
| Execution time associated with the message. | |
| ACE_Time_Value | deadline_time_ |
| Absolute deadline time for 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 |
Stores messages for use throughout ACE (particularly in an ACE_Message_Queue).
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.
| typedef int ACE_Message_Block::ACE_Message_Type |
Definition at line 119 of file Message_Block.h.
| typedef unsigned long ACE_Message_Block::Message_Flags |
Definition at line 120 of file Message_Block.h.
| anonymous enum |
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 };
| anonymous enum |
| DONT_DELETE |
Don't delete the data on exit since we don't own it. |
| USER_FLAGS |
user defined flags start here |
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 };
| ACE_Message_Block::ACE_Message_Block | ( | ACE_Allocator * | message_block_allocator = 0 |
) |
Create an empty message.
Definition at line 414 of file Message_Block.cpp.
00415 : flags_ (0), 00416 data_block_ (0) 00417 { 00418 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00419 00420 if (this->init_i (0, // size 00421 MB_DATA, // type 00422 0, // cont 00423 0, // data 00424 0, // allocator 00425 0, // locking strategy 00426 ACE_Message_Block::DONT_DELETE, // flags 00427 0, // priority 00428 ACE_Time_Value::zero, // execution time 00429 ACE_Time_Value::max_time, // absolute time of deadline 00430 0, // data block 00431 0, // data_block allocator 00432 message_block_allocator) == -1) // message_block allocator 00433 ACE_ERROR ((LM_ERROR, 00434 ACE_TEXT ("ACE_Message_Block"))); 00435 }
| ACE_Message_Block::ACE_Message_Block | ( | ACE_Data_Block * | data_block, | |
| ACE_Message_Block::Message_Flags | flags = 0, |
|||
| ACE_Allocator * | message_block_allocator = 0 | |||
| ) |
Create an ACE_Message_Block that owns the specified 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 557 of file Message_Block.cpp.
00560 : flags_ (flags), 00561 data_block_ (0) 00562 { 00563 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00564 00565 if (this->init_i (0, // size 00566 MB_NORMAL, // type 00567 0, // cont 00568 0, // data 00569 0, // allocator 00570 0, // locking strategy 00571 0, // flags 00572 0, // priority 00573 ACE_Time_Value::zero, // execution time 00574 ACE_Time_Value::max_time, // absolute time of deadline 00575 data_block, // data block 00576 data_block->data_block_allocator (), 00577 message_block_allocator) == -1) 00578 ACE_ERROR ((LM_ERROR, 00579 ACE_TEXT ("ACE_Message_Block"))); 00580 }
| ACE_Message_Block::ACE_Message_Block | ( | const char * | data, | |
| size_t | size = 0, |
|||
| unsigned long | priority = ACE_DEFAULT_MESSAGE_BLOCK_PRIORITY | |||
| ) |
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 size of the new ACE_Message_Block will be size, but the length will be 0 until the write pointer is changed.
Definition at line 389 of file Message_Block.cpp.
00392 : flags_ (0), 00393 data_block_ (0) 00394 { 00395 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00396 00397 if (this->init_i (size, // size 00398 MB_DATA, // type 00399 0, // cont 00400 data, // data 00401 0, // allocator 00402 0, // locking strategy 00403 ACE_Message_Block::DONT_DELETE, // flags 00404 priority, // priority 00405 ACE_Time_Value::zero, // execution time 00406 ACE_Time_Value::max_time, // absolute time of deadline 00407 0, // data block 00408 0, // data_block allocator 00409 0) == -1) // message_block allocator 00410 ACE_ERROR ((LM_ERROR, 00411 ACE_TEXT ("ACE_Message_Block"))); 00412 }
| ACE_Message_Block::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 | |||
| ) |
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 size of the ACE_Message_Block will be size, but the length will be 0 until the write pointer is set. The data_block_allocator is used 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 ACE_Message_Block objects when the duplicate() method is called. If a message_block_allocator is given, this ACE_Message_Block and future ACE_Message_Block objects created by duplicate() will be freed using this allocator when they are released.
Definition at line 437 of file Message_Block.cpp.
00448 :flags_ (0), 00449 data_block_ (0) 00450 { 00451 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00452 00453 if (this->init_i (size, 00454 msg_type, 00455 msg_cont, 00456 msg_data, 00457 allocator_strategy, 00458 locking_strategy, 00459 msg_data ? ACE_Message_Block::DONT_DELETE : 0, 00460 priority, 00461 execution_time, 00462 deadline_time, 00463 0, // data block 00464 data_block_allocator, 00465 message_block_allocator) == -1) 00466 ACE_ERROR ((LM_ERROR, 00467 ACE_TEXT ("ACE_Message_Block"))); 00468 }
| ACE_Message_Block::ACE_Message_Block | ( | const ACE_Message_Block & | mb, | |
| size_t | align | |||
| ) |
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 582 of file Message_Block.cpp.
00584 :flags_ (0), 00585 data_block_ (0) 00586 { 00587 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00588 00589 if (ACE_BIT_DISABLED (mb.flags_, 00590 ACE_Message_Block::DONT_DELETE)) 00591 { 00592 if (this->init_i (0, // size 00593 MB_NORMAL, // type 00594 0, // cont 00595 0, // data 00596 0, // allocator 00597 0, // locking strategy 00598 0, // flags 00599 0, // priority 00600 ACE_Time_Value::zero, // execution time 00601 ACE_Time_Value::max_time, // absolute time of deadline 00602 mb.data_block ()->duplicate (), // data block 00603 mb.data_block ()->data_block_allocator (), 00604 mb.message_block_allocator_) == -1) 00605 ACE_ERROR ((LM_ERROR, 00606 ACE_TEXT ("ACE_Message_Block"))); 00607 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 00608 // Align ourselves 00609 char *start = ACE_ptr_align_binary (this->base (), 00610 align); 00611 #else 00612 char *start = this->base (); 00613 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00614 00615 // Set our rd & wr pointers 00616 this->rd_ptr (start); 00617 this->wr_ptr (start); 00618 00619 } 00620 else 00621 { 00622 if (this->init_i (0, // size 00623 MB_NORMAL, // type 00624 0, // cont 00625 0, // data 00626 0, // allocator 00627 0, // locking strategy 00628 0, // flags 00629 0, // priority 00630 ACE_Time_Value::zero, // execution time 00631 ACE_Time_Value::max_time, // absolute time of deadline 00632 mb.data_block ()->clone_nocopy (),// data block 00633 mb.data_block ()->data_block_allocator (), 00634 mb.message_block_allocator_) == -1) 00635 ACE_ERROR ((LM_ERROR, 00636 ACE_TEXT ("ACE_Message_Block"))); 00637 00638 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 00639 // Align ourselves 00640 char *start = ACE_ptr_align_binary (this->base (), 00641 align); 00642 #else 00643 char *start = this->base (); 00644 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00645 00646 // Set our rd & wr pointers 00647 this->rd_ptr (start); 00648 this->wr_ptr (start); 00649 00650 #if !defined (ACE_LACKS_CDR_ALIGNMENT) 00651 // Get the alignment offset of the incoming ACE_Message_Block 00652 start = ACE_ptr_align_binary (mb.base (), 00653 align); 00654 #else 00655 start = mb.base (); 00656 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00657 00658 // Actual offset for the incoming message block assuming that it 00659 // is also aligned to the same "align" byte 00660 size_t const wr_offset = mb.wr_ptr_ - (start - mb.base ()); 00661 00662 // Copy wr_offset amount of data in to <this->data_block> 00663 (void) ACE_OS::memcpy (this->wr_ptr (), 00664 start, 00665 wr_offset); 00666 00667 // Dont move the write pointer, just leave it to the application 00668 // to do what it wants 00669 00670 } 00671 #if defined (ACE_LACKS_CDR_ALIGNMENT) 00672 ACE_UNUSED_ARG (align); 00673 #endif /* ACE_LACKS_CDR_ALIGNMENT */ 00674 }
| ACE_Message_Block::~ACE_Message_Block | ( | void | ) | [virtual] |
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 976 of file Message_Block.cpp.
00977 { 00978 ACE_TRACE ("ACE_Message_Block::~ACE_Message_Block"); 00979 00980 if (ACE_BIT_DISABLED (this->flags_, 00981 ACE_Message_Block::DONT_DELETE)&& 00982 this->data_block ()) 00983 this->data_block ()->release (); 00984 00985 this->prev_ = 0; 00986 this->next_ = 0; 00987 this->cont_ = 0; 00988 }
| ACE_Message_Block::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 | |||
| ) | [protected] |
Perform the actual initialization.
Definition at line 522 of file Message_Block.cpp.
00535 : flags_ (0), 00536 data_block_ (0) 00537 { 00538 ACE_TRACE ("ACE_Message_Block::ACE_Message_Block"); 00539 00540 if (this->init_i (size, 00541 msg_type, 00542 msg_cont, 00543 msg_data, 00544 allocator_strategy, 00545 locking_strategy, 00546 flags, 00547 priority, 00548 execution_time, 00549 deadline_time, 00550 db, 00551 data_block_allocator, 00552 message_block_allocator) == -1) 00553 ACE_ERROR ((LM_ERROR, 00554 ACE_TEXT ("ACE_Message_Block"))); 00555 }
| ACE_Message_Block::ACE_Message_Block | ( | const ACE_Message_Block & | ) | [private] |
| void ACE_Message_Block::access_allocators | ( | ACE_Allocator *& | allocator_strategy, | |
| ACE_Allocator *& | data_block_allocator, | |||
| ACE_Allocator *& | message_block_allocator | |||
| ) |
Access all the allocators in the message block.
This method returns the allocators only from the first message block in the chain.
| allocator_strategy | Strategy used to allocate the underlying buffer | |
| data_block_allocator | Strategy used to allocate the underlying data block | |
| message_block_allocator | Strategy used to allocate the message block |
Definition at line 272 of file Message_Block.inl.
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 }
| void ACE_Message_Block::base | ( | char * | data, | |
| size_t | size, | |||
| Message_Flags | msg_flags = DONT_DELETE | |||
| ) |
Set message data (doesn't reallocate).
Definition at line 292 of file Message_Block.inl.
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 }
| char * ACE_Message_Block::base | ( | void | ) | const |
Get message data.
Definition at line 285 of file Message_Block.inl.
00286 { 00287 ACE_TRACE ("ACE_Message_Block::base"); 00288 return this->data_block ()->base (); 00289 }
| size_t ACE_Message_Block::capacity | ( | void | ) | const |
Get the number of allocated bytes in the top-level Message_Block.
Definition at line 154 of file Message_Block.inl.
00155 { 00156 ACE_TRACE ("ACE_Message_Block::capacity"); 00157 return this->data_block ()->capacity (); 00158 }
| ACE_Message_Block * ACE_Message_Block::clone | ( | Message_Flags | mask = 0 |
) | const [virtual] |
Return an exact "deep copy" of the message, i.e., create fresh new copies of all the Data_Blocks and continuations.
Definition at line 1175 of file Message_Block.cpp.
01176 { 01177 ACE_TRACE ("ACE_Message_Block::clone"); 01178 01179 // Get a pointer to a "cloned" <ACE_Data_Block> (will copy the 01180 // values rather than increment the reference count). 01181 ACE_Data_Block *db = this->data_block ()->clone (mask); 01182 01183 if (db == 0) 01184 return 0; 01185 01186 ACE_Message_Block *nb = 0; 01187 01188 if(message_block_allocator_ == 0) 01189 { 01190 ACE_NEW_RETURN (nb, 01191 ACE_Message_Block (0, // size 01192 ACE_Message_Type (0), // type 01193 0, // cont 01194 0, // data 01195 0, // allocator 01196 0, // locking strategy 01197 0, // flags 01198 this->priority_, // priority 01199 ACE_EXECUTION_TIME, // execution time 01200 ACE_DEADLINE_TIME, // absolute time to deadline 01201 // Get a pointer to a 01202 // "duplicated" <ACE_Data_Block> 01203 // (will simply increment the 01204 // reference count). 01205 db, 01206 db->data_block_allocator (), 01207 this->message_block_allocator_), 01208 0); 01209 } 01210 else 01211 { 01212 // This is the ACE_NEW_MALLOC macro with the return check removed. 01213 // We need to do it this way because if it fails we need to release 01214 // the cloned data block that was created above. If we used 01215 // ACE_NEW_MALLOC_RETURN, there would be a memory leak because the 01216 // above db pointer would be left dangling. 01217 nb = static_cast<ACE_Message_Block*> (message_block_allocator_->malloc (sizeof (ACE_Message_Block))); 01218 if(nb != 0) 01219 new (nb) ACE_Message_Block (0, // size 01220 ACE_Message_Type (0), // type 01221 0, // cont 01222 0, // data 01223 0, // allocator 01224 0, // locking strategy 01225 0, // flags 01226 this->priority_, // priority 01227 ACE_EXECUTION_TIME, // execution time 01228 ACE_DEADLINE_TIME, // absolute time to deadline 01229 db, 01230 db->data_block_allocator (), 01231 this->message_block_allocator_); 01232 } 01233 01234 if (nb == 0) 01235 { 01236 db->release (); 01237 return 0; 01238 } 01239 01240 // Set the read and write pointers in the new <Message_Block> to the 01241 // same relative offset as in the existing <Message_Block>. 01242 nb->rd_ptr (this->rd_ptr_); 01243 nb->wr_ptr (this->wr_ptr_); 01244 01245 // Clone all the continuation messages if necessary. 01246 if (this->cont () != 0 01247 && (nb->cont_ = this->cont ()->clone (mask)) == 0) 01248 { 01249 nb->release (); 01250 return 0; 01251 } 01252 return nb; 01253 }
| ACE_Message_Block::Message_Flags ACE_Message_Block::clr_flags | ( | ACE_Message_Block::Message_Flags | less_flags | ) |
Clear the message flag bits specified in less_flags and return the new value.
Definition at line 112 of file Message_Block.inl.
00113 { 00114 ACE_TRACE ("ACE_Message_Block::clr_flags"); 00115 return this->data_block ()->clr_flags (less_flags); 00116 }
| ACE_Message_Block::Message_Flags ACE_Message_Block::clr_self_flags | ( | ACE_Message_Block::Message_Flags | less_flags | ) |
Clear the message flag bits specified in less_flags and return the new value.
Definition at line 24 of file Message_Block.inl.
| void ACE_Message_Block::cont | ( | ACE_Message_Block * | cont_msg | ) |
Set the continuation field.
Definition at line 409 of file Message_Block.inl.
| ACE_Message_Block * ACE_Message_Block::cont | ( | void | ) | const |
Get the continuation field.
Definition at line 416 of file Message_Block.inl.
| int ACE_Message_Block::copy | ( | const char * | buf | ) |
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.
| buf | Pointer to the character string to copy from. |
| 0 | on success; the write pointer is advanced by the string's length, including the 0 terminator. | |
| -1 | if the amount of free space following the write pointer in the block is less than required to hold the entire string. Free space can be checked by calling space(). |
Definition at line 102 of file Message_Block.cpp.
00103 { 00104 ACE_TRACE ("ACE_Message_Block::copy"); 00105 00106 /* size_t len = static_cast<size_t> (this->end () - this->wr_ptr ()); */ 00107 // Note that for this to work correct, end() *must* be >= wr_ptr(). 00108 size_t len = this->space (); 00109 00110 size_t buflen = ACE_OS::strlen (buf) + 1; 00111 00112 if (len < buflen) 00113 { 00114 errno = ENOSPC; 00115 return -1; 00116 } 00117 else 00118 { 00119 (void) ACE_OS::memcpy (this->wr_ptr (), 00120 buf, 00121 buflen); 00122 this->wr_ptr (buflen); 00123 return 0; 00124 } 00125 }
| int ACE_Message_Block::copy | ( | const char * | buf, | |
| size_t | n | |||
| ) |
Copies data into this ACE_Message_Block. Data is copied into the block starting at the current write pointer.
| buf | Pointer to the buffer to copy from. | |
| n | The number of bytes to copy. |
| 0 | on success; the write pointer is advanced by
| |
| -1 | if the amount of free space following the write pointer in the block is less than
|
Definition at line 78 of file Message_Block.cpp.
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 { 00088 errno = ENOSPC; 00089 return -1; 00090 } 00091 else 00092 { 00093 (void) ACE_OS::memcpy (this->wr_ptr (), 00094 buf, 00095 n); 00096 this->wr_ptr (n); 00097 return 0; 00098 } 00099 }
| int ACE_Message_Block::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 <rd_ptr> to point to <base> and <wr_ptr> to point to <base> + the length of the moved data. Returns -1 and does nothing if the <rd_ptr> is > <wr_ptr>, else 0 on success.
Definition at line 128 of file Message_Block.cpp.
00129 { 00130 if (this->rd_ptr_ != 0) 00131 { 00132 if (this->rd_ptr_ > this->wr_ptr_) 00133 return -1; 00134 00135 size_t const len = this->length (); 00136 (void) ACE_OS::memmove (this->base (), 00137 this->rd_ptr (), 00138 len); 00139 this->rd_ptr (this->base ()); 00140 this->wr_ptr (this->base () + len); 00141 } 00142 return 0; 00143 }
| void ACE_Message_Block::data_block | ( | ACE_Data_Block * | ) |
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.
| ACE_Data_Block * ACE_Message_Block::data_block | ( | void | ) | const |
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.
00009 { 00010 ACE_TRACE ("ACE_Message_Block::data_block"); 00011 return this->data_block_; 00012 }
| void ACE_Message_Block::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 174 of file Message_Block.cpp.
00175 { 00176 #if defined (ACE_HAS_DUMP) 00177 ACE_TRACE ("ACE_Message_Block::dump"); 00178 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00179 ACE_DEBUG ((LM_DEBUG, 00180 ACE_TEXT ("-----( Message Block )-----\n") 00181 ACE_TEXT ("priority_ = %d\n") 00182 ACE_TEXT ("next_ = %@\n") 00183 ACE_TEXT ("prev_ = %@\n") 00184 ACE_TEXT ("cont_ = %@\n") 00185 ACE_TEXT ("rd_ptr_ = %@\n") 00186 ACE_TEXT ("wr_ptr_ = %@\n") 00187 ACE_TEXT ("---------------------------\n"), 00188 this->priority_, 00189 this->next_, 00190 this->prev_, 00191 this->cont_, 00192 this->rd_ptr_, 00193 this->wr_ptr_)); 00194 this->data_block ()->dump (); 00195 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00196 #endif /* ACE_HAS_DUMP */ 00197 }
| ACE_Message_Block * ACE_Message_Block::duplicate | ( | const ACE_Message_Block * | mb | ) | [static] |
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 1097 of file Message_Block.cpp.
| ACE_Message_Block * ACE_Message_Block::duplicate | ( | void | ) | const [virtual] |
Return a "shallow" copy that increments our reference count by 1.
Definition at line 1018 of file Message_Block.cpp.
01019 { 01020 ACE_TRACE ("ACE_Message_Block::duplicate"); 01021 01022 ACE_Message_Block *nb = 0; 01023 01024 // Create a new <ACE_Message_Block> that contains unique copies of 01025 // the message block fields, but a reference counted duplicate of 01026 // the <ACE_Data_Block>. 01027 01028 // If there is no allocator, use the standard new and delete calls. 01029 if (this->message_block_allocator_ == 0) 01030 ACE_NEW_RETURN (nb, 01031 ACE_Message_Block (0, // size 01032 ACE_Message_Type (0), // type 01033 0, // cont 01034 0, // data 01035 0, // allocator 01036 0, // locking strategy 01037 0, // flags 01038 this->priority_, // priority 01039 ACE_EXECUTION_TIME, 01040 ACE_DEADLINE_TIME, 01041 // Get a pointer to a 01042 // "duplicated" <ACE_Data_Block> 01043 // (will simply increment the 01044 // reference count). 01045 this->data_block ()->duplicate (), 01046 this->data_block ()->data_block_allocator (), 01047 this->message_block_allocator_), 01048 0); 01049 else // Otherwise, use the message_block_allocator passed in. 01050 ACE_NEW_MALLOC_RETURN (nb, 01051 static_cast<ACE_Message_Block*> ( 01052 message_block_allocator_->malloc (sizeof (ACE_Message_Block))), 01053 ACE_Message_Block (0, // size 01054 ACE_Message_Type (0), // type 01055 0, // cont 01056 0, // data 01057 0, // allocator 01058 0, // locking strategy 01059 0, // flags 01060 this->priority_, // priority 01061 ACE_EXECUTION_TIME, 01062 ACE_DEADLINE_TIME, 01063 // Get a pointer to a 01064 // "duplicated" <ACE_Data_Block> 01065 // (will simply increment the 01066 // reference count). 01067 this->data_block ()->duplicate (), 01068 this->data_block ()->data_block_allocator (), 01069 this->message_block_allocator_), 01070 0); 01071 01072 // Set the read and write pointers in the new <Message_Block> to the 01073 // same relative offset as in the existing <Message_Block>. Note 01074 // that we are assuming that the data_block()->base() pointer 01075 // doesn't change when it's duplicated. 01076 nb->rd_ptr (this->rd_ptr_); 01077 nb->wr_ptr (this->wr_ptr_); 01078 01079 // Increment the reference counts of all the continuation messages. 01080 if (this->cont_) 01081 { 01082 nb->cont_ = this->cont_->duplicate (); 01083 01084 // If things go wrong, release all of our resources and return 01085 // 0. 01086 if (nb->cont_ == 0) 01087 { 01088 nb->release (); 01089 nb = 0; 01090 } 01091 } 01092 01093 return nb; 01094 }
| char * ACE_Message_Block::end | ( | void | ) | const |
Return a pointer to 1 past the end of the allocated data in a message.
Definition at line 340 of file Message_Block.inl.
00341 { 00342 ACE_TRACE ("ACE_Message_Block::end"); 00343 return this->data_block ()->end (); 00344 }
| ACE_Message_Block::Message_Flags ACE_Message_Block::flags | ( | void | ) | const |
Get the current message flags.
Definition at line 119 of file Message_Block.inl.
00120 { 00121 ACE_TRACE ("ACE_Message_Block::flags"); 00122 return this->data_block ()->flags (); 00123 }
| int ACE_Message_Block::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 | |||
| ) |
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_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 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 471 of file Message_Block.cpp.
00482 { 00483 ACE_TRACE ("ACE_Message_Block::init"); 00484 00485 return this->init_i (size, 00486 msg_type, 00487 msg_cont, 00488 msg_data, 00489 allocator_strategy, 00490 locking_strategy, 00491 msg_data ? ACE_Message_Block::DONT_DELETE : 0, 00492 priority, 00493 execution_time, 00494 deadline_time, 00495 0, // data block 00496 data_block_allocator, 00497 message_block_allocator); 00498 }
| int ACE_Message_Block::init | ( | const char * | data, | |
| size_t | size = 0 | |||
| ) |
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 501 of file Message_Block.cpp.
00503 { 00504 ACE_TRACE ("ACE_Message_Block::init"); 00505 // Should we also initialize all the other fields, as well? 00506 00507 return this->init_i (size, // size 00508 MB_DATA, // type 00509 0, // cont 00510 data, // data 00511 0, // allocator 00512 0, // locking strategy 00513 ACE_Message_Block::DONT_DELETE, // flags 00514 0, // priority 00515 ACE_Time_Value::zero, // execution time 00516 ACE_Time_Value::max_time, // absolute time of deadline 00517 0, // data block 00518 0, // data_block allocator 00519 0); // message_block allocator 00520 }
| int ACE_Message_Block::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 | |||
| ) | [protected] |
Perform the actual initialization.
Definition at line 677 of file Message_Block.cpp.
00690 { 00691 ACE_TRACE ("ACE_Message_Block::init_i"); 00692 ACE_FUNCTION_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_ENTER); 00693 00694 this->rd_ptr_ = 0; 00695 this->wr_ptr_ = 0; 00696 this->priority_ = priority; 00697 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS) 00698 this->execution_time_ = execution_time; 00699 this->deadline_time_ = deadline_time; 00700 #else 00701 ACE_UNUSED_ARG (execution_time); 00702 ACE_UNUSED_ARG (deadline_time); 00703 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */ 00704 this->cont_ = msg_cont; 00705 this->next_ = 0; 00706 this->prev_ = 0; 00707 00708 this->message_block_allocator_ = message_block_allocator; 00709 00710 if (this->data_block_ != 0) 00711 { 00712 this->data_block_->release (); 00713 this->data_block_ = 0; 00714 } 00715 00716 if (db == 0) 00717 { 00718 if (data_block_allocator == 0) 00719 ACE_ALLOCATOR_RETURN (data_block_allocator, 00720 ACE_Allocator::instance (), 00721 -1); 00722 00723 ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_ALLOC); 00724 00725 // Allocate the <ACE_Data_Block> portion, which is reference 00726 // counted. 00727 ACE_NEW_MALLOC_RETURN (db, 00728 static_cast<ACE_Data_Block *> ( 00729 data_block_allocator->malloc (sizeof (ACE_Data_Block))), 00730 ACE_Data_Block (size, 00731 msg_type, 00732 msg_data, 00733 allocator_strategy, 00734 locking_strategy, 00735 flags, 00736 data_block_allocator), 00737 -1); 00738 ACE_TIMEPROBE (ACE_MESSAGE_BLOCK_INIT_I_DB_CTOR); 00739 00740 // Message block initialization may fail, while the construction 00741 // succeds. Since ACE may throw no exceptions, we have to do a 00742 // separate check and clean up, like this: 00743 if (db != 0 && db->size () < size) 00744 { 00745 db->ACE_Data_Block::~ACE_Data_Block(); // placement destructor ... 00746 data_block_allocator->free (db); // free ... 00747 errno = ENOMEM; 00748 return -1; 00749 } 00750 } 00751 00752 // Reset the data_block_ pointer. 00753 this->data_block (db); 00754 00755 return 0; 00756 }
| int ACE_Message_Block::is_data_msg | ( | void | ) | const |
Find out what type of message this is.
Definition at line 202 of file Message_Block.inl.
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 }
| void ACE_Message_Block::length | ( | size_t | n | ) |
Set the length of the message.
Definition at line 138 of file Message_Block.inl.
| size_t ACE_Message_Block::length | ( | void | ) | const |
Get the length of the message.
Definition at line 128 of file Message_Block.inl.
Set a new locking strategy and return the hold one.
Definition at line 500 of file Message_Block.inl.
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 }
| ACE_Lock * ACE_Message_Block::locking_strategy | ( | void | ) |
Get the locking strategy.
Definition at line 493 of file Message_Block.inl.
00494 { 00495 ACE_TRACE ("ACE_Message_Block::locking_strategy"); 00496 return this->data_block ()->locking_strategy (); 00497 }
| char * ACE_Message_Block::mark | ( | void | ) | const |
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.
00327 { 00328 ACE_TRACE ("ACE_Message_Block::mark"); 00329 return this->data_block ()->mark (); 00330 }
| ACE_Message_Block::ACE_Message_Type ACE_Message_Block::msg_class | ( | void | ) | const |
Find out what class of message this is (there are two classes, normal messages and high-priority messages).
Definition at line 189 of file Message_Block.inl.
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 }
| void ACE_Message_Block::msg_deadline_time | ( | const ACE_Time_Value & | dt | ) |
Set absolute time of deadline associated with the message.
Definition at line 261 of file Message_Block.inl.
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 }
| const ACE_Time_Value & ACE_Message_Block::msg_deadline_time | ( | void | ) | const |
Get absolute time of deadline associated with the message.
Definition at line 249 of file Message_Block.inl.
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 }
| void ACE_Message_Block::msg_execution_time | ( | const ACE_Time_Value & | et | ) |
Set execution time associated with the message.
Definition at line 238 of file Message_Block.inl.
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 }
| const ACE_Time_Value & ACE_Message_Block::msg_execution_time | ( | void | ) | const |
Get execution time associated with the message.
Definition at line 227 of file Message_Block.inl.
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 }
| void ACE_Message_Block::msg_priority | ( | unsigned long | priority | ) |
Set priority of the message.
Definition at line 220 of file Message_Block.inl.
| unsigned long ACE_Message_Block::msg_priority | ( | void | ) | const |
Get priority of the message.
Definition at line 213 of file Message_Block.inl.
| void ACE_Message_Block::msg_type | ( | ACE_Message_Block::ACE_Message_Type | t | ) |
Set type of the message.
Definition at line 182 of file Message_Block.inl.
00183 { 00184 ACE_TRACE ("ACE_Message_Block::msg_type"); 00185 this->data_block ()->msg_type (t); 00186 }
| ACE_Message_Block::ACE_Message_Type ACE_Message_Block::msg_type | ( | void | ) | const |
Get type of the message.
Definition at line 175 of file Message_Block.inl.
00176 { 00177 ACE_TRACE ("ACE_Message_Block::msg_type"); 00178 return this->data_block ()->msg_type (); 00179 }
| void ACE_Message_Block::next | ( | ACE_Message_Block * | next_msg | ) |
Set link to next message.
Definition at line 441 of file Message_Block.inl.
| ACE_Message_Block * ACE_Message_Block::next | ( | void | ) | const |
Get link to next message.
Definition at line 448 of file Message_Block.inl.
| ACE_Message_Block & ACE_Message_Block::operator= | ( | const ACE_Message_Block & | ) | [private] |
Definition at line 1257 of file Message_Block.cpp.
01258 { 01259 ACE_TRACE ("ACE_Message_Block::operator="); 01260 return *this; 01261 }
| void ACE_Message_Block::prev | ( | ACE_Message_Block * | next_msg | ) |
Set link to prev message.
Definition at line 455 of file Message_Block.inl.
| ACE_Message_Block * ACE_Message_Block::prev | ( | void | ) | const |
Get link to prev message.
Definition at line 462 of file Message_Block.inl.
| void ACE_Message_Block::rd_ptr | ( | size_t | n | ) |
Set the read pointer ahead n bytes.
Definition at line 355 of file Message_Block.inl.
| void ACE_Message_Block::rd_ptr | ( | char * | ptr | ) |
Set the read pointer to ptr.
Definition at line 348 of file Message_Block.inl.
| char * ACE_Message_Block::rd_ptr | ( | void | ) | const |
Get the read pointer.
Definition at line 303 of file Message_Block.inl.
| int ACE_Message_Block::reference_count | ( | void | ) | const |
Get the current reference count.
Definition at line 46 of file Message_Block.inl.
00047 { 00048 return data_block () ? data_block ()->reference_count () : 0; 00049 }
| ACE_Message_Block * ACE_Message_Block::release | ( | ACE_Message_Block * | mb | ) | [static] |
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 966 of file Message_Block.cpp.
| ACE_Message_Block * ACE_Message_Block::release | ( | void | ) | [virtual] |
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.
| 0,always,and | the object this method was invoked on is no longer valid. |
Definition at line 859 of file Message_Block.cpp.
00860 { 00861 ACE_TRACE ("ACE_Message_Block::release"); 00862 00863 // We want to hold the data block in a temporary variable because we 00864 // invoked "delete this;" at some point, so using this->data_block_ 00865 // could be a bad idea. 00866 ACE_Data_Block *tmp = this->data_block (); 00867 00868 // This flag is set to 1 when we have to destroy the data_block 00869 int destroy_dblock = 0; 00870 00871 ACE_Lock *lock = 0; 00872 00873 // Do we have a valid data block 00874 if (this->data_block ()) 00875 { 00876 // Grab the lock that belongs to my data block 00877 lock = this->data_block ()->locking_strategy (); 00878 00879 // if we have a lock 00880 if (lock != 0) 00881 { 00882 // One guard for all 00883 ACE_GUARD_RETURN (ACE_Lock, ace_mon, *lock, 0); 00884 00885 // Call non-guarded release with @a lock 00886 destroy_dblock = this->release_i (lock); 00887 } 00888 // This is the case when we have a valid data block but no lock 00889 else 00890 // Call non-guarded release with no lock 00891 destroy_dblock = this->release_i (0); 00892 } 00893 else 00894 // This is the case when we don't even have a valid data block 00895 destroy_dblock = this->release_i (0); 00896 00897 if (destroy_dblock != 0) 00898 { 00899 ACE_Allocator *allocator = tmp->data_block_allocator (); 00900 ACE_DES_FREE (tmp, 00901 allocator->free, 00902 ACE_Data_Block); 00903 } 00904 00905 return 0; 00906 }
| int ACE_Message_Block::release_i | ( | ACE_Lock * | lock | ) | [protected] |
Internal release implementation Returns 1 if the data block has to be destroyed.
Definition at line 909 of file Message_Block.cpp.
00910 { 00911 ACE_TRACE ("ACE_Message_Block::release_i"); 00912 00913 // Free up all the continuation messages. 00914 if (this->cont_) 00915 { 00916 ACE_Message_Block *mb = this->cont_; 00917 ACE_Message_Block *tmp = 0; 00918 00919 do 00920 { 00921 tmp = mb; 00922 mb = mb->cont_; 00923 tmp->cont_ = 0; 00924 00925 ACE_Data_Block *db = tmp->data_block (); 00926 if (tmp->release_i (lock) != 0) 00927 { 00928 ACE_Allocator *allocator = db->data_block_allocator (); 00929 ACE_DES_FREE (db, 00930 allocator->free, 00931 ACE_Data_Block); 00932 } 00933 } 00934 while (mb); 00935 00936 this->cont_ = 0; 00937 } 00938 00939 int result = 0; 00940 00941 if (ACE_BIT_DISABLED (this->flags_, 00942 ACE_Message_Block::DONT_DELETE) && 00943 this->data_block ()) 00944 { 00945 if (this->data_block ()->release_no_delete (lock) == 0) 00946 result = 1; 00947 this->data_block_ = 0; 00948 } 00949 00950 // We will now commit suicide: this object *must* have come from the 00951 // allocator given. 00952 if (this->message_block_allocator_ == 0) 00953 delete this; 00954 else 00955 { 00956 ACE_Allocator *allocator = this->message_block_allocator_; 00957 ACE_DES_FREE (this, 00958 allocator->free, 00959 ACE_Message_Block); 00960 } 00961 00962 return result; 00963 }
| ACE_Data_Block * ACE_Message_Block::replace_data_block | ( | ACE_Data_Block * | db | ) |
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 391 of file Message_Block.inl.
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 }
| void ACE_Message_Block::reset | ( | void | ) |
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.
| void ACE_Message_Block::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.
This method resets the allocators in all the message blocks in the chain.
Definition at line 423 of file Message_Block.inl.
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 }
| ACE_Message_Block::Message_Flags ACE_Message_Block::self_flags | ( | void | ) | const |
Get the current message flags.
Definition at line 33 of file Message_Block.inl.
| ACE_Message_Block::Message_Flags ACE_Message_Block::set_flags | ( | ACE_Message_Block::Message_Flags | more_flags | ) |
Bitwise-or the more_flags into the existing message flags and return the new value.
Definition at line 105 of file Message_Block.inl.
00106 { 00107 ACE_TRACE ("ACE_Message_Block::set_flags"); 00108 return this->data_block ()->set_flags (more_flags); 00109 }
| ACE_Message_Block::Message_Flags ACE_Message_Block::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.
Definition at line 15 of file Message_Block.inl.
| int ACE_Message_Block::size | ( | size_t | length | ) |
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 246 of file Message_Block.cpp.
00247 { 00248 ACE_TRACE ("ACE_Message_Block::size"); 00249 00250 // Resize the underlying <ACE_Data_Block>. 00251 if (this->data_block ()->size (length) == -1) 00252 return -1; 00253 00254 return 0; 00255 }
| size_t ACE_Message_Block::size | ( | void | ) | const |
Get the number of bytes in the top-level Message_Block (i.e., does not consider the bytes in chained Message_Blocks).
Definition at line 147 of file Message_Block.inl.
00148 { 00149 ACE_TRACE ("ACE_Message_Block::size"); 00150 return this->data_block ()->size (); 00151 }
| size_t ACE_Message_Block::space | ( | void | ) | const |
Get the number of bytes available after the <wr_ptr_> in the top-level Message_Block.
Definition at line 384 of file Message_Block.inl.
| size_t ACE_Message_Block::total_capacity | ( | void | ) | const |
Get the number of allocated bytes in all Message_Block, including chained Message_Blocks.
Definition at line 301 of file Message_Block.cpp.
00302 { 00303 ACE_TRACE ("ACE_Message_Block::total_capacity"); 00304 00305 size_t size = 0; 00306 00307 for (const ACE_Message_Block *i = this; 00308 i != 0; 00309 i = i->cont ()) 00310 size += i->capacity (); 00311 00312 return size; 00313 }
| size_t ACE_Message_Block::total_length | ( | void | ) | const |
Get the length of the Message_Blocks, including chained Message_Blocks.
Definition at line 287 of file Message_Block.cpp.
00288 { 00289 ACE_TRACE ("ACE_Message_Block::total_length"); 00290 00291 size_t length = 0; 00292 for (const ACE_Message_Block *i = this; 00293 i != 0; 00294 i = i->cont ()) 00295 length += i->length (); 00296 00297 return length; 00298 }
| size_t ACE_Message_Block::total_size | ( | void | ) | const |
Get the total number of bytes in all Message_Blocks, including chained Message_Blocks.
Definition at line 273 of file Message_Block.cpp.
00274 { 00275 ACE_TRACE ("ACE_Message_Block::total_size"); 00276 00277 size_t size = 0; 00278 for (const ACE_Message_Block *i = this; 00279 i != 0; 00280 i = i->cont ()) 00281 size += i->size (); 00282 00283 return size; 00284 }
| void ACE_Message_Block::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_Blocks, including chained Message_Blocks.
Definition at line 258 of file Message_Block.cpp.
00260 { 00261 ACE_TRACE ("ACE_Message_Block::total_size_and_length"); 00262 00263 for (const ACE_Message_Block *i = this; 00264 i != 0; 00265 i = i->cont ()) 00266 { 00267 mb_size += i->size (); 00268 mb_length += i->length (); 00269 } 00270 }
| void ACE_Message_Block::wr_ptr | ( | size_t | n | ) |
Set the write pointer ahead n bytes. This is used to compute the <length> of a message.
Definition at line 369 of file Message_Block.inl.
| void ACE_Message_Block::wr_ptr | ( | char * | ptr | ) |
Set the write pointer to ptr.
Definition at line 310 of file Message_Block.inl.
| char * ACE_Message_Block::wr_ptr | ( | void | ) | const |
Get the write pointer.
Definition at line 362 of file Message_Block.inl.
friend class ACE_Data_Block [friend] |
Definition at line 62 of file Message_Block.h.
Declare the dynamic allocation hooks.
Definition at line 583 of file Message_Block.h.
ACE_Message_Block* ACE_Message_Block::cont_ [protected] |
Pointer to next message block in the chain.
Definition at line 640 of file Message_Block.h.
ACE_Data_Block* ACE_Message_Block::data_block_ [protected] |
Pointer to the reference counted data structure that contains the actual memory buffer.
Definition at line 653 of file Message_Block.h.
ACE_Time_Value ACE_Message_Block::deadline_time_ [protected] |
Absolute deadline time for message.
Definition at line 635 of file Message_Block.h.
ACE_Time_Value ACE_Message_Block::execution_time_ [protected] |
Execution time associated with the message.
Definition at line 632 of file Message_Block.h.
Misc flags (e.g., DONT_DELETE and USER_FLAGS).
Definition at line 649 of file Message_Block.h.
ACE_Allocator* ACE_Message_Block::message_block_allocator_ [protected] |
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.
ACE_Message_Block* ACE_Message_Block::next_ [protected] |
Pointer to next message in the list.
Definition at line 643 of file Message_Block.h.
ACE_Message_Block* ACE_Message_Block::prev_ [protected] |
Pointer to previous message in the list.
Definition at line 646 of file Message_Block.h.
unsigned long ACE_Message_Block::priority_ [protected] |
Priority of message.
Definition at line 628 of file Message_Block.h.
size_t ACE_Message_Block::rd_ptr_ [protected] |
Pointer to beginning of next read.
Definition at line 622 of file Message_Block.h.
size_t ACE_Message_Block::wr_ptr_ [protected] |
Pointer to beginning of next write.
Definition at line 625 of file Message_Block.h.
1.6.1