ThreadStrategyFactoryImpl.cpp

Go to the documentation of this file.
00001 // ThreadStrategyFactoryImpl.cpp,v 1.9 2006/03/10 07:19:16 jtc Exp
00002 
00003 #include "tao/PortableServer/ThreadStrategyFactoryImpl.h"
00004 #include "tao/PortableServer/ThreadStrategy.h"
00005 #include "ace/Dynamic_Service.h"
00006 #include "ace/Log_Msg.h"
00007 
00008 ACE_RCSID (PortableServer,
00009            ThreadStrategyFactoryImpl,
00010            "ThreadStrategyFactoryImpl.cpp,v 1.9 2006/03/10 07:19:16 jtc Exp")
00011 
00012 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00013 
00014 namespace TAO
00015 {
00016   namespace Portable_Server
00017   {
00018     ThreadStrategy*
00019     ThreadStrategyFactoryImpl::create (
00020       ::PortableServer::ThreadPolicyValue value)
00021     {
00022       ThreadStrategy* strategy = 0;
00023 
00024       switch (value)
00025       {
00026         case ::PortableServer::SINGLE_THREAD_MODEL :
00027         {
00028           ThreadStrategyFactory *strategy_factory =
00029             ACE_Dynamic_Service<ThreadStrategyFactory>::instance ("ThreadStrategySingleFactory");
00030 
00031           if (strategy_factory != 0)
00032             strategy = strategy_factory->create (value);
00033           else
00034             ACE_ERROR ((LM_ERROR,
00035                         ACE_TEXT ("(%P|%t) %p\n"),
00036                         ACE_TEXT ("ERROR, Unable to get ")
00037                         ACE_TEXT ("ThreadStrategySingleFactory")));
00038 
00039           break;
00040         }
00041         case ::PortableServer::ORB_CTRL_MODEL :
00042         {
00043           strategy =
00044             ACE_Dynamic_Service<ThreadStrategy>::instance ("ThreadStrategyORBControl");
00045 
00046           if (strategy == 0)
00047             ACE_ERROR ((LM_ERROR,
00048                         ACE_TEXT ("(%P|%t) %p\n"),
00049                         ACE_TEXT ("ERROR, Unable to get ")
00050                         ACE_TEXT ("ThreadStrategyORBControl")));
00051 
00052           break;
00053         }
00054       }
00055 
00056       return strategy;
00057     }
00058 
00059     void
00060     ThreadStrategyFactoryImpl::destroy (
00061       ThreadStrategy *strategy
00062       ACE_ENV_ARG_DECL)
00063     {
00064       switch (strategy->type ())
00065       {
00066         case ::PortableServer::SINGLE_THREAD_MODEL :
00067         {
00068           ThreadStrategyFactory *strategy_factory =
00069             ACE_Dynamic_Service<ThreadStrategyFactory>::instance ("ThreadStrategySingleFactory");
00070 
00071           if (strategy_factory != 0)
00072             {
00073               strategy_factory->destroy (strategy ACE_ENV_ARG_PARAMETER);
00074               ACE_CHECK;
00075             }
00076           break;
00077         }
00078         case ::PortableServer::ORB_CTRL_MODEL :
00079         {
00080           // Noop
00081           break;
00082         }
00083       }
00084     }
00085   }
00086 }
00087 
00088 TAO_END_VERSIONED_NAMESPACE_DECL
00089 
00090 ACE_STATIC_SVC_DEFINE (
00091   ThreadStrategyFactoryImpl,
00092   ACE_TEXT ("ThreadStrategyFactory"),
00093   ACE_SVC_OBJ_T,
00094   &ACE_SVC_NAME (ThreadStrategyFactoryImpl),
00095   ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00096   0)
00097 
00098 ACE_FACTORY_NAMESPACE_DEFINE (
00099   ACE_Local_Service,
00100   ThreadStrategyFactoryImpl,
00101   TAO::Portable_Server::ThreadStrategyFactoryImpl)
00102 

Generated on Thu Nov 9 12:40:45 2006 for TAO_PortableServer by doxygen 1.3.6