Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

TAO_Advanced_Resource_Factory Class Reference

TAO's default resource factory. More...

#include <advanced_resource.h>

Inheritance diagram for TAO_Advanced_Resource_Factory:
Inheritance graph
[legend]
Collaboration diagram for TAO_Advanced_Resource_Factory:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Allocator_Lock_Type { TAO_ALLOCATOR_NULL_LOCK, TAO_ALLOCATOR_THREAD_LOCK }
 

Type of lock used for the allocators.

More...
enum  {
  TAO_REACTOR_SELECT_MT = 1, TAO_REACTOR_SELECT_ST = 2, TAO_REACTOR_WFMO = 3, TAO_REACTOR_MSGWFMO = 4,
  TAO_REACTOR_TP = 5, TAO_REACTOR_DEV_POLL = 6
}
 

Type of Reactor.

More...
enum  { TAO_THREAD_QUEUE_NOT_SET, TAO_THREAD_QUEUE_FIFO, TAO_THREAD_QUEUE_LIFO }
 

Thread queueing Strategy.

More...

Public Member Functions

 TAO_Advanced_Resource_Factory (void)
 Constructor.
virtual ~TAO_Advanced_Resource_Factory (void)
 Destructor.
virtual int init (int argc, ACE_TCHAR *argv[])
 Dynamic linking hook.
virtual
TAO_Connection_Purging_Strategy
create_purging_strategy (void)
 Modify and get the source for the CDR allocators.
virtual TAO_LF_Strategycreate_lf_strategy (void)
 Modify and get the source for the CDR allocators.
Resource Retrieval

virtual int init_protocol_factories (void)
 Modify and get the source for the CDR allocators.
virtual ACE_Allocatorinput_cdr_dblock_allocator (void)
 Modify and get the source for the CDR allocators.
virtual ACE_Allocatorinput_cdr_buffer_allocator (void)
 Modify and get the source for the CDR allocators.
virtual ACE_Allocatorinput_cdr_msgblock_allocator (void)
 Modify and get the source for the CDR allocators.
virtual ACE_Allocatoramh_response_handler_allocator (void)
 Modify and get the source for the CDR allocators.
virtual ACE_Allocatorami_response_handler_allocator (void)
 Modify and get the source for the CDR allocators.
virtual int input_cdr_allocator_type_locked (void)
 Modify and get the source for the CDR allocators.
virtual TAO_ProtocolFactorySetget_protocol_factories (void)
 Modify and get the source for the CDR allocators.

Protected Member Functions

virtual ACE_Reactor_Implallocate_reactor_impl (void) const
 Obtain the reactor implementation.
void report_option_value_error (const ACE_TCHAR *option_name, const ACE_TCHAR *option_value)
void report_unsupported_error (const ACE_TCHAR *option_name)
virtual int load_default_protocols (void)

Protected Attributes

TAO_ProtocolFactorySet protocol_factories_
 List of loaded protocol factories.
int reactor_registry_type_
 The type of reactor registry.
int reactor_type_
 Flag indicating which kind of reactor we should use.
int threadqueue_type_
Allocator_Lock_Type cdr_allocator_type_
 The type of CDR allocators.
Allocator_Lock_Type amh_response_handler_allocator_lock_type_
 Type of lock used by AMH response handler allocator.
Allocator_Lock_Type ami_response_handler_allocator_lock_type_
 Type of lock used by AMI response handler allocator.

Detailed Description

TAO's default resource factory.

Using a <{resource source specifier}> as a discriminator, the factory can return resource instances which are, e.g., global, stored in thread-specific storage, stored in shared memory, etc.

Definition at line 39 of file advanced_resource.h.


Member Enumeration Documentation

anonymous enum

Type of Reactor.

Enumerator:
TAO_REACTOR_SELECT_MT 

Use ACE_Token.

TAO_REACTOR_SELECT_ST 

Use ACE_Noop_Token.

TAO_REACTOR_WFMO 
TAO_REACTOR_MSGWFMO 
TAO_REACTOR_TP 
TAO_REACTOR_DEV_POLL 

Definition at line 62 of file advanced_resource.h.

  {
    /// Use ACE_Token
    TAO_REACTOR_SELECT_MT = 1,

    /// Use ACE_Noop_Token
    TAO_REACTOR_SELECT_ST = 2,
    TAO_REACTOR_WFMO      = 3,
    TAO_REACTOR_MSGWFMO   = 4,
    TAO_REACTOR_TP        = 5,
    TAO_REACTOR_DEV_POLL  = 6
  };

anonymous enum

Thread queueing Strategy.

Enumerator:
TAO_THREAD_QUEUE_NOT_SET 

Not set, use LIFO.

TAO_THREAD_QUEUE_FIFO 

FIFO, first-in-first-out.

TAO_THREAD_QUEUE_LIFO 

LIFO, last-in-first-out (default).

Definition at line 76 of file advanced_resource.h.

  {
    /// Not set, use LIFO.
    TAO_THREAD_QUEUE_NOT_SET,

    /// FIFO, first-in-first-out.
    TAO_THREAD_QUEUE_FIFO,

    /// LIFO, last-in-first-out (default).
    TAO_THREAD_QUEUE_LIFO
  };

Type of lock used for the allocators.

Enumerator:
TAO_ALLOCATOR_NULL_LOCK 
TAO_ALLOCATOR_THREAD_LOCK 

Definition at line 55 of file advanced_resource.h.

  {
    TAO_ALLOCATOR_NULL_LOCK,
    TAO_ALLOCATOR_THREAD_LOCK
  };


Constructor & Destructor Documentation

TAO_Advanced_Resource_Factory::TAO_Advanced_Resource_Factory ( void   ) 
TAO_Advanced_Resource_Factory::~TAO_Advanced_Resource_Factory ( void   )  [virtual]

Destructor.

Definition at line 83 of file advanced_resource.cpp.

{
  // Destructor
  TAO_ProtocolFactorySetItor end = this->protocol_factories_.end ();

  for (TAO_ProtocolFactorySetItor iterator =
         this->protocol_factories_.begin ();
       iterator != end;
       ++iterator)
    delete *iterator;

  this->protocol_factories_.reset ();
}


Member Function Documentation

ACE_Reactor_Impl * TAO_Advanced_Resource_Factory::allocate_reactor_impl ( void   )  const [protected, virtual]

Obtain the reactor implementation.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 419 of file advanced_resource.cpp.

{
  ACE_Reactor_Impl *impl = 0;

  /*
   * Hook for specializing the Reactor implementation in TAO.
   */
//@@ TAO_ADVANCED_RESOURCE_REACTOR_SPL_COMMENT_HOOK_START
  switch (this->reactor_type_)
    {
    case TAO_REACTOR_SELECT_MT:
      ACE_NEW_RETURN (impl,
                      TAO_REACTOR ((ACE_Sig_Handler*)0,
                                   (ACE_Timer_Queue*)0,
                                   0,
                                   (ACE_Reactor_Notify*)0,
                                   this->reactor_mask_signals_),
                      0);
      break;

    case TAO_REACTOR_SELECT_ST:
      ACE_NEW_RETURN (impl,
                      TAO_NULL_LOCK_REACTOR ((ACE_Sig_Handler*)0,
                                             (ACE_Timer_Queue*)0,
                                             0,
                                             (ACE_Reactor_Notify*)0,
                                             this->reactor_mask_signals_),
                      0);
      break;

    case TAO_REACTOR_WFMO:
#if defined(ACE_WIN32)
      ACE_NEW_RETURN (impl, ACE_WFMO_Reactor, 0);
#endif /* ACE_WIN32 */
      break;

#if defined(ACE_WIN32) \
  && !defined (ACE_LACKS_MSG_WFMO) \
  && !defined (ACE_HAS_WINCE)      \
  && !defined (ACE_HAS_PHARLAP)
    case TAO_REACTOR_MSGWFMO:
      ACE_NEW_RETURN (impl, ACE_Msg_WFMO_Reactor, 0);
      break;
#endif /* ACE_WIN32 && !ACE_LACKS_MSG_WFMO */

#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
    case TAO_REACTOR_DEV_POLL:
      ACE_NEW_RETURN (impl,
                      ACE_Dev_Poll_Reactor (ACE::max_handles (),
                                            1,  // restart
                                            (ACE_Sig_Handler*)0,
                                            (ACE_Timer_Queue*)0,
                                            0, // Do not disable notify
                                            0, // Allocate notify handler
                                            this->reactor_mask_signals_,
                                            ACE_Select_Reactor_Token::LIFO),
                      0);
      break;
#endif  /* ACE_HAS_EVENT_POLL || ACE_HAS_DEV_POLL */

    default:
    case TAO_REACTOR_TP:
      ACE_NEW_RETURN (impl,
          ACE_TP_Reactor (ACE::max_handles (),
              1,
              (ACE_Sig_Handler*)0,
              (ACE_Timer_Queue*)0,
              this->reactor_mask_signals_,
              this->threadqueue_type_ == TAO_THREAD_QUEUE_FIFO ?
              ACE_Select_Reactor_Token::FIFO :
              ACE_Select_Reactor_Token::LIFO),
          0);
      break;
    }

//@@ TAO_ADVANCED_RESOURCE_REACTOR_SPL_COMMENT_HOOK_END

  return impl;
}

ACE_Allocator * TAO_Advanced_Resource_Factory::amh_response_handler_allocator ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 559 of file advanced_resource.cpp.

{
  ACE_Allocator *allocator = 0;
  switch (this->amh_response_handler_allocator_lock_type_)
    {
    case TAO_ALLOCATOR_NULL_LOCK:
      ACE_NEW_RETURN (allocator,
                      NULL_LOCK_ALLOCATOR,
                      0);
      break;
    default:
      return
        this->TAO_Default_Resource_Factory::amh_response_handler_allocator();
    }

  return allocator;
}

ACE_Allocator * TAO_Advanced_Resource_Factory::ami_response_handler_allocator ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 578 of file advanced_resource.cpp.

{
  ACE_Allocator *allocator = 0;
  switch (this->ami_response_handler_allocator_lock_type_)
    {
    case TAO_ALLOCATOR_NULL_LOCK:
      ACE_NEW_RETURN (allocator,
                      NULL_LOCK_ALLOCATOR,
                      0);
      break;
    default:
      return
        this->TAO_Default_Resource_Factory::ami_response_handler_allocator();
    }

  return allocator;
}

TAO_LF_Strategy * TAO_Advanced_Resource_Factory::create_lf_strategy ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 644 of file advanced_resource.cpp.

{
  TAO_LF_Strategy *strategy = 0;

  if (this->reactor_type_ == TAO_REACTOR_SELECT_ST)
    {
      ACE_NEW_RETURN (strategy,
                      TAO_LF_Strategy_Null,
                      0);
    }
  else
    {
      ACE_NEW_RETURN (strategy,
                      TAO_LF_Strategy_Complete,
                      0);
    }
  return strategy;
}

TAO_Connection_Purging_Strategy * TAO_Advanced_Resource_Factory::create_purging_strategy ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 603 of file advanced_resource.cpp.

{
  TAO_Connection_Purging_Strategy *strategy = 0;

  switch(this->connection_purging_type_)
    {
    case TAO_Resource_Factory::LFU:
      ACE_NEW_RETURN (strategy,
                      TAO_LFU_Connection_Purging_Strategy (
                                               this->cache_maximum ()),
                      0);
      break;
    case TAO_Resource_Factory::FIFO:
      ACE_NEW_RETURN (strategy,
                      TAO_FIFO_Connection_Purging_Strategy (
                                               this->cache_maximum ()),
                      0);
      break;
    case TAO_Resource_Factory::NOOP:
      ACE_NEW_RETURN (strategy,
                      TAO_NULL_Connection_Purging_Strategy (
                                               this->cache_maximum ()),
                      0);
      break;
    case TAO_Resource_Factory::LRU:
      ACE_NEW_RETURN (strategy,
                      TAO_LRU_Connection_Purging_Strategy (
                                               this->cache_maximum ()),
                      0);
      break;
    default:
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT("TAO (%P|%t) - ")
                  ACE_TEXT("Unknown connection purging strategy ")
                  ACE_TEXT("type was found.\n")));
    }

  return strategy;
}

TAO_ProtocolFactorySet * TAO_Advanced_Resource_Factory::get_protocol_factories ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 413 of file advanced_resource.cpp.

{
  return &protocol_factories_;
}

virtual int TAO_Advanced_Resource_Factory::init ( int  argc,
ACE_TCHAR argv[] 
) [virtual]

Dynamic linking hook.

Reimplemented from TAO_Default_Resource_Factory.

int TAO_Advanced_Resource_Factory::init_protocol_factories ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 327 of file advanced_resource.cpp.

{
  // If the default resource factory exists, then disable it.
  // This causes any directives for the "Resource_Factory" to
  // report warnings.
  // This is needed to ensure warnings when no static directive
  // for this factory is used (and init() is not called).
  TAO_Resource_Factory *default_resource_factory =
    ACE_Dynamic_Service<TAO_Resource_Factory>::instance ("Resource_Factory");
  if (default_resource_factory != 0)
    {
      default_resource_factory->disable_factory();
    }

  TAO_ProtocolFactorySetItor end = protocol_factories_.end ();
  TAO_ProtocolFactorySetItor factory = protocol_factories_.begin ();

  if (factory == end)
    {
      int const r = this->load_default_protocols ();

      if (r == -1)
        return -1;

#if TAO_HAS_UIOP == 1
      if (TAO::details::load_protocol_factory <TAO_UIOP_Protocol_Factory> (
          this->protocol_factories_, "UIOP_Factory") == -1)
        return -1;
#endif /* TAO_HAS_UIOP == 1 */

#if defined (TAO_HAS_SHMIOP) && (TAO_HAS_SHMIOP != 0)
      if (TAO::details::load_protocol_factory <TAO_SHMIOP_Protocol_Factory> (
          this->protocol_factories_, "SHMIOP_Factory") == -1)
        return -1;
#endif /* TAO_HAS_SHMIOP && TAO_HAS_SHMIOP != 0 */

#if defined (TAO_HAS_DIOP) && (TAO_HAS_DIOP != 0)
      if (TAO::details::load_protocol_factory <TAO_DIOP_Protocol_Factory> (
          this->protocol_factories_, "DIOP_Factory") == -1)
        return -1;
#endif /* TAO_HAS_DIOP && TAO_HAS_DIOP != 0 */

#if defined (TAO_HAS_SCIOP) && (TAO_HAS_SCIOP != 0)
      if (TAO::details::load_protocol_factory <TAO_SCIOP_Protocol_Factory> (
          this->protocol_factories_, "SCIOP_Factory") == -1)
        return -1;
#endif /* TAO_HAS_SCIOP && TAO_HAS_SCIOP != 0 */

#if defined (TAO_HAS_COIOP) && (TAO_HAS_COIOP != 0)
      if (TAO::details::load_protocol_factory <TAO_COIOP_Protocol_Factory> (
          this->protocol_factories_, "COIOP_Factory") == -1)
        return -1;
#endif /* TAO_HAS_COIOP && TAO_HAS_COIOP != 0 */

      return 0;

    }

  for (; factory != end; factory++)
    {
      const ACE_CString &name = (*factory)->protocol_name ();

      (*factory)->factory (
        ACE_Dynamic_Service<TAO_Protocol_Factory>::instance (name.c_str ()));
      if ((*factory)->factory () == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT("TAO (%P|%t) Unable to load ")
                             ACE_TEXT("protocol <%C>, %m\n"),
                             name.c_str ()),
                            -1);
        }

      if (TAO_debug_level > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT("TAO (%P|%t) Loaded protocol <%C>\n"),
                      name.c_str ()));
        }
    }
 return 0;
}

int TAO_Advanced_Resource_Factory::input_cdr_allocator_type_locked ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 597 of file advanced_resource.cpp.

{
  return this->cdr_allocator_type_ == TAO_ALLOCATOR_NULL_LOCK ? 0 : 1;
}

ACE_Allocator * TAO_Advanced_Resource_Factory::input_cdr_buffer_allocator ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 522 of file advanced_resource.cpp.

{
  ACE_Allocator *allocator = 0;
  switch (this->cdr_allocator_type_)
    {
    case TAO_ALLOCATOR_NULL_LOCK:
      ACE_NEW_RETURN (allocator,
                      NULL_LOCK_ALLOCATOR,
                      0);
      break;
    default:
      return
        this->TAO_Default_Resource_Factory::input_cdr_buffer_allocator();
    }
  return allocator;
}

ACE_Allocator * TAO_Advanced_Resource_Factory::input_cdr_dblock_allocator ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 503 of file advanced_resource.cpp.

{
  ACE_Allocator *allocator = 0;
  switch (this->cdr_allocator_type_)
    {
    case TAO_ALLOCATOR_NULL_LOCK:
      ACE_NEW_RETURN (allocator,
                      NULL_LOCK_ALLOCATOR,
                      0);
      break;
    default:
      return
        this->TAO_Default_Resource_Factory::input_cdr_dblock_allocator();
    }

  return allocator;
}

ACE_Allocator * TAO_Advanced_Resource_Factory::input_cdr_msgblock_allocator ( void   )  [virtual]

Modify and get the source for the CDR allocators.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 540 of file advanced_resource.cpp.

{
  ACE_Allocator *allocator = 0;
  switch (this->cdr_allocator_type_)
    {
    case TAO_ALLOCATOR_NULL_LOCK:
      ACE_NEW_RETURN (allocator,
                      NULL_LOCK_ALLOCATOR,
                      0);
      break;
    default:
      return
        this->TAO_Default_Resource_Factory::input_cdr_msgblock_allocator();
    }

  return allocator;
}

int TAO_Advanced_Resource_Factory::load_default_protocols ( void   )  [protected, virtual]

Loads the default protocols. This method is used so that the advanced_resource.cpp can call the one in default_resource.cpp without calling unnecessary functions.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 308 of file advanced_resource.cpp.

{
  int const r =
    this->TAO_Default_Resource_Factory::load_default_protocols ();

  this->protocol_factories_ =
    this->TAO_Default_Resource_Factory::protocol_factories_;

  this->TAO_Default_Resource_Factory::protocol_factories_.reset ();

  if (r == -1)
    return -1;
  // Load the UIOP and SHMIOP protocols...

  return 0;
}

void TAO_Advanced_Resource_Factory::report_option_value_error ( const ACE_TCHAR option_name,
const ACE_TCHAR option_value 
) [protected]

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 664 of file advanced_resource.cpp.

{
  ACE_DEBUG((LM_DEBUG,
             ACE_TEXT("Advanced_Resource_Factory - unknown argument")
             ACE_TEXT(" <%s> for <%s>\n"),
             option_value,
             option_name));
}

void TAO_Advanced_Resource_Factory::report_unsupported_error ( const ACE_TCHAR option_name  )  [protected]

Definition at line 676 of file advanced_resource.cpp.

{
  ACE_DEBUG((LM_DEBUG,
             ACE_TEXT("Advanced_Resource_Factory - <%s>")
             ACE_TEXT(" not supported on this platform\n"),
             option_name));
}


Member Data Documentation

Type of lock used by AMH response handler allocator.

Definition at line 132 of file advanced_resource.h.

Type of lock used by AMI response handler allocator.

Definition at line 135 of file advanced_resource.h.

The type of CDR allocators.

Definition at line 129 of file advanced_resource.h.

List of loaded protocol factories.

Reimplemented from TAO_Default_Resource_Factory.

Definition at line 116 of file advanced_resource.h.

The type of reactor registry.

Definition at line 119 of file advanced_resource.h.

Flag indicating which kind of reactor we should use.

Definition at line 122 of file advanced_resource.h.

The type of queueing strategy to use for multi-threaded select reactors, TAO_REACTOR_SELECT_MT and TAO_REACTOR_TP.

Definition at line 126 of file advanced_resource.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines