ThreadStrategyFactoryImpl.cpp

Go to the documentation of this file.
00001 // $Id: ThreadStrategyFactoryImpl.cpp 76551 2007-01-24 13:42:44Z johnnyw $
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            "$Id: ThreadStrategyFactoryImpl.cpp 76551 2007-01-24 13:42:44Z johnnyw $")
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       )
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);
00074             }
00075           break;
00076         }
00077         case ::PortableServer::ORB_CTRL_MODEL :
00078         {
00079           // Noop
00080           break;
00081         }
00082       }
00083     }
00084   }
00085 }
00086 
00087 TAO_END_VERSIONED_NAMESPACE_DECL
00088 
00089 ACE_STATIC_SVC_DEFINE (
00090   ThreadStrategyFactoryImpl,
00091   ACE_TEXT ("ThreadStrategyFactory"),
00092   ACE_SVC_OBJ_T,
00093   &ACE_SVC_NAME (ThreadStrategyFactoryImpl),
00094   ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00095   0)
00096 
00097 ACE_FACTORY_NAMESPACE_DEFINE (
00098   ACE_Local_Service,
00099   ThreadStrategyFactoryImpl,
00100   TAO::Portable_Server::ThreadStrategyFactoryImpl)
00101 

Generated on Tue Feb 2 17:40:54 2010 for TAO_PortableServer by  doxygen 1.4.7