GUIResource_Factory.cpp

Go to the documentation of this file.
00001 //GUIResource_Factory.cpp,v 1.3 2005/11/02 07:13:03 ossama Exp
00002 #include "tao/GUIResource_Factory.h"
00003 #include "ace/Reactor.h"
00004 #include "tao/debug.h"
00005 
00006 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00007 
00008 namespace TAO
00009 {
00010   GUIResource_Factory::GUIResource_Factory (void)
00011     : dynamically_allocated_reactor_ (0)
00012   {
00013   }
00014 
00015   GUIResource_Factory::~GUIResource_Factory (void)
00016   {
00017   }
00018 
00019   ACE_Reactor *
00020   GUIResource_Factory::get_reactor (void)
00021   {
00022     // @@Marek, do we need a lock here??
00023     // @Bala, I suppose we don't need locking for any
00024     //   reasonable use case as this
00025     //   factory is intended to be a variable in TSS.
00026     //   I can imagine that    someone may try to use it in distinct
00027     //   threads, though I do not know
00028     //   what for. Nevertheless, just for a case  I sync the creation of reactor.
00029     //   I think, that double checked locking is
00030     //   not necessary, because the performance is not an issue here.
00031     ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
00032 
00033     ACE_Reactor *reactor = 0;
00034     ACE_NEW_RETURN (reactor,
00035                     ACE_Reactor (this->reactor_impl (), 1),
00036                     0);
00037 
00038     if (reactor->initialized () == 0)
00039     {
00040       delete reactor;
00041       reactor = 0;
00042     }
00043     else
00044       this->dynamically_allocated_reactor_ = 1;
00045 
00046     return reactor;
00047   }
00048 
00049   void
00050   GUIResource_Factory::reclaim_reactor (ACE_Reactor *reactor)
00051   {
00052     ACE_GUARD ( TAO_SYNCH_MUTEX, ace_mon, this->lock_ );
00053 
00054     if (this->dynamically_allocated_reactor_ == 1)
00055       delete reactor;
00056   }
00057 }
00058 
00059 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 11:54:12 2006 for TAO by doxygen 1.3.6