From a75c149af7ad0324ef2a41750b54f8665da558a5 Mon Sep 17 00:00:00 2001 From: coryan Date: Wed, 14 Oct 1998 04:24:34 +0000 Subject: ChangeLogTag:Tue Oct 13 23:03:24 1998 Carlos O'Ryan --- TAO/tao/CDR.cpp | 39 ++++++++++++-------------------- TAO/tao/CDR.h | 17 ++++++++------ TAO/tao/Connect.cpp | 6 ++--- TAO/tao/Invocation.i | 8 +++---- TAO/tao/ORB_Core.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ TAO/tao/ORB_Core.h | 9 ++++++++ TAO/tao/ORB_Core.i | 6 +++++ 7 files changed, 108 insertions(+), 41 deletions(-) (limited to 'TAO/tao') diff --git a/TAO/tao/CDR.cpp b/TAO/tao/CDR.cpp index 8cfc0d127ef..656dc0d111b 100644 --- a/TAO/tao/CDR.cpp +++ b/TAO/tao/CDR.cpp @@ -580,18 +580,8 @@ TAO_OutputCDR::write_boolean_array (const CORBA::Boolean* x, TAO_InputCDR::TAO_InputCDR (const char *buf, size_t bufsiz, int byte_order, - TAO_Marshal_Factory *factory, - ACE_Allocator* buffer_allocator, - ACE_Allocator* data_block_allocator) - : start_ (bufsiz, - ACE_Message_Block::MB_DATA, - 0, - buf, - buffer_allocator, - 0, 0, - ACE_Time_Value::zero, - ACE_Time_Value::max_time, - data_block_allocator), + TAO_Marshal_Factory *factory) + : start_ (buf, bufsiz), factory_ (factory), do_byte_swap_ (byte_order != TAO_ENCAP_BYTE_ORDER), good_bit_ (1) @@ -601,19 +591,8 @@ TAO_InputCDR::TAO_InputCDR (const char *buf, size_t bufsiz, TAO_InputCDR::TAO_InputCDR (size_t bufsiz, int byte_order, - TAO_Marshal_Factory *factory, - ACE_Allocator* buffer_allocator, - ACE_Allocator* data_block_allocator) - : start_ (bufsiz, - ACE_Message_Block::MB_DATA, - 0, - 0, - buffer_allocator, - 0, - 0, - ACE_Time_Value::zero, - ACE_Time_Value::max_time, - data_block_allocator), + TAO_Marshal_Factory *factory) + : start_ (bufsiz), factory_ (factory), do_byte_swap_ (byte_order != TAO_ENCAP_BYTE_ORDER), good_bit_ (1) @@ -632,6 +611,16 @@ TAO_InputCDR::TAO_InputCDR (ACE_Message_Block *data, this->start_.wr_ptr (data->wr_ptr ()); } +TAO_InputCDR::TAO_InputCDR (ACE_Data_Block *data, + int byte_order, + TAO_Marshal_Factory *factory) + : start_ (data), + factory_ (factory), + do_byte_swap_ (byte_order != TAO_ENCAP_BYTE_ORDER), + good_bit_ (1) +{ +} + TAO_InputCDR::TAO_InputCDR (const TAO_InputCDR& rhs, size_t size, CORBA::Long offset) diff --git a/TAO/tao/CDR.h b/TAO/tao/CDR.h index 7d6a8f61cd4..2b9bad27554 100644 --- a/TAO/tao/CDR.h +++ b/TAO/tao/CDR.h @@ -386,9 +386,7 @@ public: TAO_InputCDR (const char* buf, size_t bufsiz, int byte_order = TAO_ENCAP_BYTE_ORDER, TAO_Marshal_Factory *f = - TAO_Marshal::DEFAULT_MARSHAL_FACTORY, - ACE_Allocator* buffer_allocator = 0, - ACE_Allocator* data_block_allocator = 0); + TAO_Marshal::DEFAULT_MARSHAL_FACTORY); // Create an input stream from an arbitrary buffer, care must be // exercised wrt alignment, because this contructor will *not* work // if the buffer is unproperly aligned. @@ -396,11 +394,9 @@ public: TAO_InputCDR (size_t bufsiz, int byte_order = TAO_ENCAP_BYTE_ORDER, TAO_Marshal_Factory *f = - TAO_Marshal::DEFAULT_MARSHAL_FACTORY, - ACE_Allocator* buffer_allocator = 0, - ACE_Allocator* data_block_allocator = 0); + TAO_Marshal::DEFAULT_MARSHAL_FACTORY); // Create an empty input stream. The caller is responsible for - // putting the right data in here. + // putting the right data and providing the right alignment. TAO_InputCDR (ACE_Message_Block *data, int byte_order = @@ -409,6 +405,13 @@ public: TAO_Marshal::DEFAULT_MARSHAL_FACTORY); // Create an input stream from an ACE_Message_Block + TAO_InputCDR (ACE_Data_Block *data, + int byte_order = + TAO_ENCAP_BYTE_ORDER, + TAO_Marshal_Factory *f = + TAO_Marshal::DEFAULT_MARSHAL_FACTORY); + // Create an input stream from an ACE_Data_Block + TAO_InputCDR (const TAO_InputCDR& rhs); TAO_InputCDR& operator= (const TAO_InputCDR& rhs); // Make a copy of the current stream state, but does not copy the diff --git a/TAO/tao/Connect.cpp b/TAO/tao/Connect.cpp index 592ca4da861..14b9a0a7e83 100644 --- a/TAO/tao/Connect.cpp +++ b/TAO/tao/Connect.cpp @@ -507,11 +507,9 @@ TAO_Server_Connection_Handler::handle_input (ACE_HANDLE) // @@ TODO This should take its memory from a specialized // allocator. It is better to use a message block than a on stack // buffer because we cannot minimize memory copies in that case. - TAO_InputCDR input (CDR::DEFAULT_BUFSIZE, + TAO_InputCDR input (this->orb_core_->create_input_cdr_data_block (CDR::DEFAULT_BUFSIZE), TAO_ENCAP_BYTE_ORDER, - TAO_Marshal::DEFAULT_MARSHAL_FACTORY, - this->orb_core_->input_cdr_buffer_allocator (), - this->orb_core_->input_cdr_dblock_allocator ()); + TAO_Marshal::DEFAULT_MARSHAL_FACTORY); char repbuf[CDR::DEFAULT_BUFSIZE]; #if defined(ACE_HAS_PURIFY) diff --git a/TAO/tao/Invocation.i b/TAO/tao/Invocation.i index e7fd39edc7c..6195b9db53a 100644 --- a/TAO/tao/Invocation.i +++ b/TAO/tao/Invocation.i @@ -25,11 +25,9 @@ TAO_GIOP_Twoway_Invocation (IIOP_Object *data, const char *operation, TAO_ORB_Core *orb_core) : TAO_GIOP_Invocation (data, operation, orb_core), - inp_stream_ (CDR::DEFAULT_BUFSIZE, + inp_stream_ (orb_core->create_input_cdr_data_block (CDR::DEFAULT_BUFSIZE), TAO_ENCAP_BYTE_ORDER, - TAO_Marshal::DEFAULT_MARSHAL_FACTORY, - orb_core->input_cdr_buffer_allocator (), - orb_core->input_cdr_dblock_allocator ()) + TAO_Marshal::DEFAULT_MARSHAL_FACTORY) { } @@ -83,7 +81,7 @@ TAO_GIOP_Locate_Request_Invocation:: TAO_GIOP_Locate_Request_Invocation (IIOP_Object *data, TAO_ORB_Core *orb_core) : TAO_GIOP_Invocation (data, 0, orb_core), - inp_stream_ (CDR::DEFAULT_BUFSIZE) + inp_stream_ (orb_core->create_input_cdr_data_block (CDR::DEFAULT_BUFSIZE)) { } diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 9e90410d7b3..6412289288d 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -1457,6 +1457,66 @@ TAO_Resource_Factory::input_cdr_buffer_allocator (void) } +ACE_Data_Block* +TAO_Resource_Factory::create_input_cdr_data_block (size_t size) +{ + switch (this->cdr_allocator_source_) + { + case TAO_GLOBAL: + { + ACE_Allocator* buffer_alloc = + this->input_cdr_buffer_allocator (); + ACE_Allocator* dblock_alloc = + this->input_cdr_dblock_allocator (); + + typedef + ACE_Locked_Data_Block > + Global_Data_Block; + Global_Data_Block *nb; + + ACE_NEW_MALLOC_RETURN ( + nb, + ACE_static_cast(Global_Data_Block*, + dblock_alloc->malloc (sizeof (Global_Data_Block))), + Global_Data_Block (size, + ACE_Message_Block::MB_DATA, + 0, + buffer_alloc, + 0, + dblock_alloc), + 0); + return nb; + } + break; + + case TAO_TSS: + { + ACE_Allocator* buffer_alloc = + this->input_cdr_buffer_allocator (); + ACE_Allocator* dblock_alloc = + this->input_cdr_dblock_allocator (); + + ACE_Data_Block *nb; + + ACE_NEW_MALLOC_RETURN ( + nb, + ACE_static_cast(ACE_Data_Block*, + dblock_alloc->malloc (sizeof (ACE_Data_Block))), + ACE_Data_Block (size, + ACE_Message_Block::MB_DATA, + 0, + buffer_alloc, + 0, + 0, + dblock_alloc), + 0); + return nb; + } + break; + } + return 0; +} + TAO_GLOBAL_Collocation_Table * TAO_Resource_Factory::get_global_collocation_table (void) { @@ -1527,6 +1587,8 @@ TAO_ORB_Core_instance (void) template class ACE_Malloc; template class ACE_Allocator_Adapter >; +template class ACE_Locked_Data_Block >; + template class ACE_Env_Value; template class ACE_Env_Value; template class ACE_Strategy_Acceptor; @@ -1579,6 +1641,8 @@ template class ACE_Select_Reactor_T< ACE_Select_Reactor_Token_T #pragma instantiate ACE_Malloc #pragma instantiate ACE_Allocator_Adapter > +#pragma instantiate ACE_Locked_Data_Block > + #pragma instantiate ACE_Env_Value #pragma instantiate ACE_Env_Value #pragma instantiate ACE_Strategy_Acceptor diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 00efa3c8270..ad32d380f9c 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -250,6 +250,10 @@ public: // This allocator is always TSS and has no locks. It is intended for // allocating the buffers used in *outgoing* CDR streams. + ACE_Data_Block *create_input_cdr_data_block (size_t size); + // The Message Blocks used for input CDRs must have appropiate + // locking strategies. + CORBA_Environment *default_environment (void) const; void default_environment (CORBA_Environment*); // The thread has a default environment to simplify porting between @@ -531,6 +535,10 @@ public: virtual ACE_Allocator* input_cdr_buffer_allocator (void); // Access the input CDR allocators. + ACE_Data_Block *create_input_cdr_data_block (size_t size); + // The Message Blocks used for input CDRs must have appropiate + // locking strategies. + // @@ I suspect that putting these structs inside of this class is // going to break some compilers (e.g., HP/YUX) when you try to use // this stuff with the ACE_Singletons below. I suggest you move @@ -613,6 +621,7 @@ public: ACE_Allocator *input_cdr_dblock_allocator_; ACE_Allocator *input_cdr_buffer_allocator_; // The allocators for the input CDR streams. + }; protected: diff --git a/TAO/tao/ORB_Core.i b/TAO/tao/ORB_Core.i index 383a0347b4c..66e4cfd8be2 100644 --- a/TAO/tao/ORB_Core.i +++ b/TAO/tao/ORB_Core.i @@ -157,6 +157,12 @@ TAO_ORB_Core::default_environment (CORBA_Environment* env) this->default_environment_ = env; } +ACE_INLINE ACE_Data_Block* +TAO_ORB_Core::create_input_cdr_data_block (size_t size) +{ + return this->resource_factory ()->create_input_cdr_data_block (size); +} + // **************************************************************** ACE_INLINE void -- cgit v1.2.1