#include <GUIResource_Factory.h>
Public Member Functions | |
GUIResource_Factory () | |
virtual | ~GUIResource_Factory () |
virtual ACE_Reactor * | get_reactor (void) |
virtual void | reclaim_reactor (ACE_Reactor *) |
Protected Member Functions | |
virtual ACE_Reactor_Impl * | reactor_impl (void)=0 |
Private Attributes | |
bool | dynamically_allocated_reactor_ |
TAO_SYNCH_MUTEX | lock_ |
for internal locking. |
This base class for resource factories which provide GUIReactors integrated with specific GUI event loop. In general, children of this class reimplement reactor_impl method where specific GUIReactor is created. GUIResource_Factory are usually created by GUIResource_Loader subclasses. Children of this class will be held in TSS by the ORB Core.
Definition at line 48 of file GUIResource_Factory.h.
TAO::GUIResource_Factory::GUIResource_Factory | ( | ) |
Definition at line 10 of file GUIResource_Factory.cpp.
00011 : dynamically_allocated_reactor_ (false) 00012 { 00013 }
TAO::GUIResource_Factory::~GUIResource_Factory | ( | ) | [virtual] |
ACE_Reactor * TAO::GUIResource_Factory::get_reactor | ( | void | ) | [virtual] |
Create ACE_Reactor using allocate_reactor_impl. Please note that this call is NOT synchronized. Left to the higher level versions to synchronize access.
Definition at line 20 of file GUIResource_Factory.cpp.
References ACE_GUARD_RETURN, ACE_NEW_RETURN, dynamically_allocated_reactor_, ACE_Reactor::initialized(), and TAO_SYNCH_MUTEX.
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_ = true; 00045 00046 return reactor; 00047 }
virtual ACE_Reactor_Impl* TAO::GUIResource_Factory::reactor_impl | ( | void | ) | [protected, pure virtual] |
Create or return current reactor instance. Please note that this call is NOT synchronized. Left to the get_reactor to synchronize access.
void TAO::GUIResource_Factory::reclaim_reactor | ( | ACE_Reactor * | ) | [virtual] |
Reclaim the reactor if allocated by this factory. Please note that this call is NOT synchronized. Left to the higher level versions to synchronize access.
Definition at line 50 of file GUIResource_Factory.cpp.
References ACE_GUARD, and TAO_SYNCH_MUTEX.
00051 { 00052 ACE_GUARD ( TAO_SYNCH_MUTEX, ace_mon, this->lock_ ); 00053 00054 if (this->dynamically_allocated_reactor_) 00055 delete reactor; 00056 }
bool TAO::GUIResource_Factory::dynamically_allocated_reactor_ [private] |
Flag that is set to true if the reactor obtained from the get_reactor() method is dynamically allocated. If this flag is set to true, then the reclaim_reactor() method with call the delete operator on the given reactor. This flag is necessary to make sure that a reactor not allocated by the default resource factory is not reclaimed by the default resource factory. Such a situation can occur when a resource factory derived from the default one overrides the get_reactor() method but does not override the reclaim_reactor() method.
Definition at line 91 of file GUIResource_Factory.h.
Referenced by get_reactor().
TAO_SYNCH_MUTEX TAO::GUIResource_Factory::lock_ [private] |