Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Asynch_Queued_Message Class Reference

Specialize TAO_Queued_Message for asynch requests, i.e. oneways sent with SYNC_NONE policy. More...

#include <Asynch_Queued_Message.h>

Inheritance diagram for TAO_Asynch_Queued_Message:

Inheritance graph
[legend]
Collaboration diagram for TAO_Asynch_Queued_Message:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_Asynch_Queued_Message (const ACE_Message_Block *contents, ACE_Allocator *alloc=0, int is_heap_allocated=0)
 Constructor. More...

virtual ~TAO_Asynch_Queued_Message (void)
 Destructor. More...

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_Messageclone (ACE_Allocator *alloc)
 NOTE: No reason to belive why this would be called. But have it here for the sake of uniformity. More...

virtual void destroy (void)

Protected Methods

 TAO_Asynch_Queued_Message (char *buf, size_t size, ACE_Allocator *alloc=0)
 Constructor. More...


Private Attributes

size_t size_
 The number of bytes in the buffer. More...

size_t offset_
 The offset in the buffer. More...

char * buffer_
 The buffer containing the complete message. More...


Detailed Description

Specialize TAO_Queued_Message for asynch requests, i.e. oneways sent with SYNC_NONE policy.

Definition at line 30 of file Asynch_Queued_Message.h.


Constructor & Destructor Documentation

TAO_Asynch_Queued_Message::TAO_Asynch_Queued_Message const ACE_Message_Block   contents,
ACE_Allocator   alloc = 0,
int    is_heap_allocated = 0
 

Constructor.

Parameters:
contents  The message block chain that must be sent.
alloc  Allocator used for creating <this> object.
Todo:
I'm almost sure this class will require a callback interface for AMIs sent with SYNC_NONE policy. Those guys need to hear when the connection timeouts or closes, but cannot block waiting for the message to be delivered.

Definition at line 14 of file Asynch_Queued_Message.cpp.

References ACE_NEW, ACE_Message_Block::cont, ACE_Message_Block::length, ACE_OS_String::memcpy, ACE_Message_Block::rd_ptr, size_, and ACE_Message_Block::total_length.

Referenced by clone.

00017   : TAO_Queued_Message (alloc, is_heap_allocated)
00018   , offset_ (0)
00019 {
00020   this->size_ = contents->total_length ();
00021   // @@ Use a pool for these guys!!
00022   ACE_NEW (this->buffer_, char[this->size_]);
00023 
00024   size_t copy_offset = 0;
00025   for (const ACE_Message_Block *i = contents;
00026        i != 0;
00027        i = i->cont ())
00028     {
00029       ACE_OS::memcpy (this->buffer_ + copy_offset,
00030                       i->rd_ptr (),
00031                       i->length ());
00032       copy_offset += i->length ();
00033     }
00034 }

TAO_Asynch_Queued_Message::~TAO_Asynch_Queued_Message void    [virtual]
 

Destructor.

Definition at line 46 of file Asynch_Queued_Message.cpp.

References buffer_.

00047 {
00048   // @@ Use a pool for these guys!
00049   delete[] this->buffer_;
00050 }

TAO_Asynch_Queued_Message::TAO_Asynch_Queued_Message char *    buf,
size_t    size,
ACE_Allocator   alloc = 0
[protected]
 

Constructor.

Parameters:
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!
size  The size of the buffer <buf> that is being handed over.
alloc  Allocator used for creating <this> object.

Definition at line 36 of file Asynch_Queued_Message.cpp.

00039   : TAO_Queued_Message (alloc)
00040   , size_ (size)
00041   , offset_ (0)
00042   , buffer_ (buf)
00043 {
00044 }


Member Function Documentation

int TAO_Asynch_Queued_Message::all_data_sent void    const [virtual]
 

Implement the Template Methods from TAO_Queued_Message

Implements TAO_Queued_Message.

Definition at line 59 of file Asynch_Queued_Message.cpp.

References offset_, and size_.

Referenced by bytes_transferred.

00060 {
00061   return this->size_ == this->offset_;
00062 }

void TAO_Asynch_Queued_Message::bytes_transferred size_t &    byte_count [virtual]
 

Implement the Template Methods from TAO_Queued_Message

Implements TAO_Queued_Message.

Definition at line 79 of file Asynch_Queued_Message.cpp.

References all_data_sent, TAO_LF_Event::LFS_ACTIVE, TAO_LF_Event::LFS_SUCCESS, offset_, size_, TAO_LF_Event::state_changed, and TAO_LF_Invocation_Event::state_changed_i.

00080 {
00081   this->state_changed_i (TAO_LF_Event::LFS_ACTIVE);
00082 
00083   size_t remaining_bytes = this->size_ - this->offset_;
00084   if (byte_count > remaining_bytes)
00085     {
00086       this->offset_ = this->size_;
00087       byte_count -= remaining_bytes;
00088       return;
00089     }
00090   this->offset_ += byte_count;
00091   byte_count = 0;
00092 
00093   if (this->all_data_sent ())
00094     this->state_changed (TAO_LF_Event::LFS_SUCCESS);
00095 }

TAO_Queued_Message * TAO_Asynch_Queued_Message::clone ACE_Allocator   alloc [virtual]
 

NOTE: No reason to belive why this would be called. But have it here for the sake of uniformity.

@

Implements TAO_Queued_Message.

Definition at line 99 of file Asynch_Queued_Message.cpp.

References ACE_DEBUG, ACE_NEW_MALLOC_RETURN, ACE_NEW_RETURN, TAO_Queued_Message::is_heap_created_, LM_DEBUG, ACE_Allocator::malloc, ACE_OS_String::memcpy, offset_, size_, and TAO_Asynch_Queued_Message.

00100 {
00101   char *buf = 0;
00102 
00103   // @@todo: Need to use a memory pool. But certain things need to
00104   // change a bit in this class for that. Till then.
00105 
00106   // Just allocate and copy data that needs to be sent, no point
00107   // copying the whole buffer.
00108   size_t sz = this->size_ - this->offset_;
00109 
00110   ACE_NEW_RETURN (buf,
00111                   char[sz],
00112                   0);
00113 
00114   ACE_OS::memcpy (buf,
00115                   this->buffer_ + this->offset_,
00116                   sz);
00117 
00118   TAO_Asynch_Queued_Message *qm = 0;
00119 
00120   if (alloc)
00121     {
00122       ACE_NEW_MALLOC_RETURN (qm,
00123                              ACE_static_cast (TAO_Asynch_Queued_Message *,
00124                                  alloc->malloc (sizeof (TAO_Asynch_Queued_Message))),
00125                              TAO_Asynch_Queued_Message (buf,
00126                                                         sz,
00127                                                         alloc),
00128                              0);
00129     }
00130   else
00131     {
00132       // No allocator, so use the common heap!
00133       if (TAO_debug_level == 4)
00134         {
00135           // This debug is for testing purposes!
00136           ACE_DEBUG ((LM_DEBUG,
00137                       "TAO (%P|%t) - Asynch_Queued_Message::clone\n",
00138                       "Using global pool for allocation \n"));
00139         }
00140 
00141       ACE_NEW_RETURN (qm,
00142                       TAO_Asynch_Queued_Message (buf,
00143                                                  sz),
00144                       0);
00145     }
00146 
00147   // Set the flag to indicate that <qm> is created on the heap.
00148   if (qm)
00149     qm->is_heap_created_ = 1;
00150 
00151   return qm;
00152 }

void TAO_Asynch_Queued_Message::destroy void    [virtual]
 

Implement the Template Methods from TAO_Queued_Message

Implements TAO_Queued_Message.

Definition at line 155 of file Asynch_Queued_Message.cpp.

References ACE_DES_FREE, TAO_Queued_Message::allocator_, and TAO_Queued_Message::is_heap_created_.

00156 {
00157   if (this->is_heap_created_)
00158     {
00159       // If we have an allocator release the memory to the allocator
00160       // pool.
00161       if (this->allocator_)
00162         {
00163           ACE_DES_FREE (this,
00164                         this->allocator_->free,
00165                         TAO_Asynch_Queued_Message);
00166 
00167         }
00168       else // global release..
00169         {
00170           delete this;
00171         }
00172     }
00173 
00174 }

void TAO_Asynch_Queued_Message::fill_iov int    iovcnt_max,
int &    iovcnt,
iovec    iov[]
const [virtual]
 

Implement the Template Methods from TAO_Queued_Message

Implements TAO_Queued_Message.

Definition at line 65 of file Asynch_Queued_Message.cpp.

References ACE_ASSERT, buffer_, iovec::iov_base, iovec::iov_len, and offset_.

00068 {
00069   ACE_ASSERT (iovcnt_max > iovcnt);
00070   ACE_UNUSED_ARG (iovcnt_max); // not used if ACE_ASSERT() is empty
00071 
00072   iov[iovcnt].iov_base = this->buffer_ + this->offset_;
00073   iov[iovcnt].iov_len  = ACE_static_cast(u_long,
00074                                          this->size_ - this->offset_);
00075   iovcnt++;
00076 }

size_t TAO_Asynch_Queued_Message::message_length void    const [virtual]
 

Implement the Template Methods from TAO_Queued_Message

Implements TAO_Queued_Message.

Definition at line 53 of file Asynch_Queued_Message.cpp.

References offset_, and size_.

00054 {
00055   return this->size_ - this->offset_;
00056 }


Member Data Documentation

char* TAO_Asynch_Queued_Message::buffer_ [private]
 

The buffer containing the complete message.

Definition at line 93 of file Asynch_Queued_Message.h.

Referenced by fill_iov, and ~TAO_Asynch_Queued_Message.

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 90 of file Asynch_Queued_Message.h.

Referenced by all_data_sent, bytes_transferred, clone, fill_iov, and message_length.

size_t TAO_Asynch_Queued_Message::size_ [private]
 

The number of bytes in the buffer.

Definition at line 83 of file Asynch_Queued_Message.h.

Referenced by all_data_sent, bytes_transferred, clone, message_length, and TAO_Asynch_Queued_Message.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:03:38 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002