Specialize TAO_Queued_Message for asynch requests, i.e. oneways sent with SYNC_NONE policy. More...
#include <Asynch_Queued_Message.h>
Public Member Functions | |
TAO_Asynch_Queued_Message (const ACE_Message_Block *contents, TAO_ORB_Core *oc, ACE_Time_Value *timeout, ACE_Allocator *alloc, bool is_heap_allocated) | |
Constructor. | |
virtual | ~TAO_Asynch_Queued_Message (void) |
Destructor. | |
Implement the Template Methods from TAO_Queued_Message | |
virtual size_t | message_length (void) const |
virtual int | all_data_sent (void) const |
virtual void | fill_iov (int iovcnt_max, int &iovcnt, iovec iov[]) const |
virtual void | bytes_transferred (size_t &byte_count) |
virtual TAO_Queued_Message * | clone (ACE_Allocator *alloc) |
virtual void | destroy (void) |
virtual bool | is_expired (const ACE_Time_Value &now) const |
virtual void | copy_if_necessary (const ACE_Message_Block *chain) |
Protected Member Functions | |
TAO_Asynch_Queued_Message (char *buf, TAO_ORB_Core *oc, size_t size, const ACE_Time_Value &abs_timeout, ACE_Allocator *alloc, bool is_heap_allocated) | |
Constructor. | |
Private Member Functions | |
void | operator= (const TAO_Asynch_Queued_Message &) |
TAO_Asynch_Queued_Message (const TAO_Asynch_Queued_Message &) | |
Private Attributes | |
size_t const | size_ |
The number of bytes in the buffer. | |
size_t | offset_ |
The offset in the buffer. | |
char * | buffer_ |
The buffer containing the complete message. | |
ACE_Time_Value | abs_timeout_ |
Specialize TAO_Queued_Message for asynch requests, i.e. oneways sent with SYNC_NONE policy.
Definition at line 39 of file Asynch_Queued_Message.h.
TAO_Asynch_Queued_Message::TAO_Asynch_Queued_Message | ( | const ACE_Message_Block * | contents, | |
TAO_ORB_Core * | oc, | |||
ACE_Time_Value * | timeout, | |||
ACE_Allocator * | alloc, | |||
bool | is_heap_allocated | |||
) |
Constructor.
contents | The message block chain that must be sent. | |
alloc | Allocator used for creating this object. | |
timeout | The relative timeout after which this message should be expired. |
Definition at line 19 of file Asynch_Queued_Message.cpp.
: TAO_Queued_Message (oc, alloc, is_heap_allocated) , size_ (contents->total_length ()) , offset_ (0) , abs_timeout_ (ACE_Time_Value::zero) { if (timeout != 0)// && *timeout != ACE_Time_Value::zero) { this->abs_timeout_ = ACE_High_Res_Timer::gettimeofday_hr () + *timeout; } // @@ Use a pool for these guys!! ACE_NEW (this->buffer_, char[this->size_]); size_t copy_offset = 0; for (const ACE_Message_Block *i = contents; i != 0; i = i->cont ()) { ACE_OS::memcpy (this->buffer_ + copy_offset, i->rd_ptr (), i->length ()); copy_offset += i->length (); } }
TAO_Asynch_Queued_Message::~TAO_Asynch_Queued_Message | ( | void | ) | [virtual] |
Destructor.
Definition at line 63 of file Asynch_Queued_Message.cpp.
{ // @@ Use a pool for these guys! delete [] this->buffer_; }
TAO_Asynch_Queued_Message::TAO_Asynch_Queued_Message | ( | char * | buf, | |
TAO_ORB_Core * | oc, | |||
size_t | size, | |||
const ACE_Time_Value & | abs_timeout, | |||
ACE_Allocator * | alloc, | |||
bool | is_heap_allocated | |||
) | [protected] |
Constructor.
buf | The buffer that needs to be sent on the wire. The buffer will be owned by this class. The buffer will be deleted when the destructor is called and hence the buffer should always come off the heap! | |
oc | The ORB Core | |
size | The size of the buffer <buf> that is being handed over. | |
abs_timeout | The time after which this message should be expired. | |
alloc | Allocator used for creating <this> object. |
Definition at line 49 of file Asynch_Queued_Message.cpp.
: TAO_Queued_Message (oc, alloc, is_heap_allocated) , size_ (size) , offset_ (0) , buffer_ (buf) , abs_timeout_ (abs_timeout) { }
TAO_Asynch_Queued_Message::TAO_Asynch_Queued_Message | ( | const TAO_Asynch_Queued_Message & | ) | [private] |
int TAO_Asynch_Queued_Message::all_data_sent | ( | void | ) | const [virtual] |
Implements TAO_Queued_Message.
Definition at line 76 of file Asynch_Queued_Message.cpp.
void TAO_Asynch_Queued_Message::bytes_transferred | ( | size_t & | byte_count | ) | [virtual] |
Implements TAO_Queued_Message.
Definition at line 95 of file Asynch_Queued_Message.cpp.
{ this->state_changed_i (TAO_LF_Event::LFS_ACTIVE); size_t const remaining_bytes = this->size_ - this->offset_; if (byte_count > remaining_bytes) { this->offset_ = this->size_; byte_count -= remaining_bytes; return; } this->offset_ += byte_count; byte_count = 0; if (this->all_data_sent ()) this->state_changed (TAO_LF_Event::LFS_SUCCESS, this->orb_core_->leader_follower ()); }
TAO_Queued_Message * TAO_Asynch_Queued_Message::clone | ( | ACE_Allocator * | alloc | ) | [virtual] |
Implements TAO_Queued_Message.
Definition at line 116 of file Asynch_Queued_Message.cpp.
{ char *buf = 0; // @todo: Need to use a memory pool. But certain things need to // change a bit in this class for that. Till then. // Just allocate and copy data that needs to be sent, no point // copying the whole buffer. size_t const sz = this->size_ - this->offset_; ACE_NEW_RETURN (buf, char[sz], 0); ACE_OS::memcpy (buf, this->buffer_ + this->offset_, sz); TAO_Asynch_Queued_Message *qm = 0; if (alloc) { ACE_NEW_MALLOC_RETURN (qm, static_cast<TAO_Asynch_Queued_Message *> ( alloc->malloc (sizeof (TAO_Asynch_Queued_Message))), TAO_Asynch_Queued_Message (buf, this->orb_core_, sz, this->abs_timeout_, alloc, true), 0); } else { // No allocator, so use the common heap! if (TAO_debug_level == 4) { // This debug is for testing purposes! ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - Asynch_Queued_Message::clone\n" "Using global pool for allocation\n")); } ACE_NEW_RETURN (qm, TAO_Asynch_Queued_Message (buf, this->orb_core_, sz, this->abs_timeout_, 0, true), 0); } return qm; }
void TAO_Asynch_Queued_Message::copy_if_necessary | ( | const ACE_Message_Block * | chain | ) | [virtual] |
Implements TAO_Queued_Message.
Definition at line 210 of file Asynch_Queued_Message.cpp.
{
// It's never necessary for asynchronously queued messages
}
void TAO_Asynch_Queued_Message::destroy | ( | void | ) | [virtual] |
Implements TAO_Queued_Message.
Definition at line 175 of file Asynch_Queued_Message.cpp.
{ if (this->is_heap_created_) { // If we have an allocator release the memory to the allocator // pool. if (this->allocator_) { ACE_DES_FREE (this, this->allocator_->free, TAO_Asynch_Queued_Message); } else // global release.. { delete this; } } }
void TAO_Asynch_Queued_Message::fill_iov | ( | int | iovcnt_max, | |
int & | iovcnt, | |||
iovec | iov[] | |||
) | const [virtual] |
Implements TAO_Queued_Message.
Definition at line 82 of file Asynch_Queued_Message.cpp.
{ ACE_ASSERT (iovcnt_max > iovcnt); ACE_UNUSED_ARG (iovcnt_max); // not used if ACE_ASSERT() is empty iov[iovcnt].iov_base = this->buffer_ + this->offset_; iov[iovcnt].iov_len = static_cast<u_long> (this->size_ - this->offset_); ++iovcnt; }
bool TAO_Asynch_Queued_Message::is_expired | ( | const ACE_Time_Value & | now | ) | const [virtual] |
Reimplemented from TAO_Queued_Message.
Definition at line 196 of file Asynch_Queued_Message.cpp.
{ if (this->abs_timeout_ > ACE_Time_Value::zero) { if (this->offset_ > 0) { return false; //never expire partial messages } return this->abs_timeout_ < now; } return false; }
size_t TAO_Asynch_Queued_Message::message_length | ( | void | ) | const [virtual] |
Implements TAO_Queued_Message.
Definition at line 70 of file Asynch_Queued_Message.cpp.
void TAO_Asynch_Queued_Message::operator= | ( | const TAO_Asynch_Queued_Message & | ) | [private] |
Definition at line 125 of file Asynch_Queued_Message.h.
char* TAO_Asynch_Queued_Message::buffer_ [private] |
The buffer containing the complete message.
Definition at line 122 of file Asynch_Queued_Message.h.
size_t TAO_Asynch_Queued_Message::offset_ [private] |
The offset in the buffer.
Data up to offset
has been sent already, only the [offset_,size_) range remains to be sent.
Definition at line 119 of file Asynch_Queued_Message.h.
size_t const TAO_Asynch_Queued_Message::size_ [private] |
The number of bytes in the buffer.
Definition at line 112 of file Asynch_Queued_Message.h.