From 89cc09fe1f27e1aa6f68baaee74657f5c0d5bf4e Mon Sep 17 00:00:00 2001 From: mbrudka Date: Sat, 22 Jan 2005 19:00:49 +0000 Subject: ChangeLogTag: Sat Jan 22 19:57:16 2005 Marek Brudka --- TAO/ChangeLog | 22 ++++++++++++++++++++++ TAO/tao/FlResource_Factory.cpp | 11 +++++++---- TAO/tao/FlResource_Factory.h | 29 ++++++++++++++++++----------- TAO/tao/FlResource_Loader.cpp | 11 +++++++++-- TAO/tao/FlResource_Loader.h | 27 +++++++++++++++++---------- TAO/tao/GUIResource_Factory.cpp | 19 ++++++++++++++++--- TAO/tao/GUIResource_Factory.h | 39 ++++++++++++++++++++++++++------------- TAO/tao/QtResource_Factory.cpp | 9 ++++----- TAO/tao/QtResource_Factory.h | 12 +++++++++++- TAO/tao/QtResource_Loader.cpp | 4 +++- TAO/tao/QtResource_Loader.h | 17 ++++++++--------- TAO/tao/TkResource_Factory.cpp | 11 +++++++---- TAO/tao/TkResource_Factory.h | 30 ++++++++++++++++++++---------- TAO/tao/TkResource_Loader.cpp | 11 +++++++++-- TAO/tao/TkResource_Loader.h | 26 ++++++++++++++++---------- TAO/tao/XtResource_Factory.cpp | 14 +++++++++----- TAO/tao/XtResource_Factory.h | 14 ++++++++------ TAO/tao/XtResource_Loader.cpp | 11 +++++++++-- TAO/tao/XtResource_Loader.h | 26 ++++++++++++++++---------- 19 files changed, 235 insertions(+), 108 deletions(-) diff --git a/TAO/ChangeLog b/TAO/ChangeLog index eaa491429b1..cb82fa51f40 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,25 @@ +Sat Jan 22 19:57:16 2005 Marek Brudka + + * tao/XtResource_Loader.h (Module): + * tao/XtResource_Loader.cpp (Module): + * tao/XtResource_Factory.h (Module): + * tao/XtResource_Factory.cpp (Module): + * tao/TkResource_Loader.h (Module): + * tao/TkResource_Loader.cpp (Module): + * tao/TkResource_Factory.h (Module): + * tao/TkResource_Factory.cpp (Module): + * tao/QtResource_Loader.h (Module): + * tao/QtResource_Loader.cpp (Module): + * tao/QtResource_Factory.h (Module): + * tao/QtResource_Factory.cpp (Module): + * tao/GUIResource_Factory.h (Module): + * tao/GUIResource_Factory.cpp (Module): + * tao/FlResource_Loader.h (Module): + * tao/FlResource_Loader.cpp (Module): + * tao/FlResource_Factory.h (Module): + * tao/FlResource_Factory.cpp (Module): + Style changes, addedin internal locking in factory when creating reactor. + Wed Jan 19 22:52:34 2005 Marek Brudka * tests/Xt_Stopwatch/server.cpp: diff --git a/TAO/tao/FlResource_Factory.cpp b/TAO/tao/FlResource_Factory.cpp index ca557486f17..b0529d29a0e 100644 --- a/TAO/tao/FlResource_Factory.cpp +++ b/TAO/tao/FlResource_Factory.cpp @@ -1,10 +1,12 @@ //$Id$ -#include /**/ "FlResource_Factory.h" -#include /**/ "debug.h" -#include /**/ "ace/FlReactor.h" +#include "FlResource_Factory.h" +#include "debug.h" +#include "ace/FlReactor.h" -ACE_RCSID(tao, FlResource_Factory, "$Id$"); +ACE_RCSID( TAO_FlResource, + FlResource_Factory, + "$Id$"); namespace TAO { @@ -17,6 +19,7 @@ namespace TAO ACE_Reactor_Impl * FlResource_Factory::reactor_impl (void) { + // synchronized by external locks if (!this->reactor_impl_) { ACE_NEW_RETURN (this->reactor_impl_, diff --git a/TAO/tao/FlResource_Factory.h b/TAO/tao/FlResource_Factory.h index ec3254239ac..ab34c6ef503 100644 --- a/TAO/tao/FlResource_Factory.h +++ b/TAO/tao/FlResource_Factory.h @@ -10,12 +10,12 @@ * @author Marek Brudka */ //============================================================================= -#ifndef _TAO_FLRESOURCE_FACTORY_H -#define _TAO_FLRESOURCE_FACTORY_H +#ifndef TAO_FLRESOURCE_FACTORY_H +#define TAO_FLRESOURCE_FACTORY_H #include /**/ "ace/pre.h" -#include /**/ "ace/FlReactor.h" -#include /**/ "TAO_FlResource_Export.h" -#include /**/ "GUIResource_Factory.h" +#include "ace/FlReactor.h" +#include "tao/TAO_FlResource_Export.h" +#include "tao/GUIResource_Factory.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -23,18 +23,25 @@ namespace TAO { - - /** TAO_GUI_Resource_Factory for creating FlReactor. + /** + * @class FlResource_Factory + * + * @brief TAO_GUI_Resource_Factory for creating FlReactor. * - * This factory is intended for creating FlReactor for ORB. This factory can be - * feed into ORB using TAO_ORB_Core::set_gui_resource_factory method which is - * usually done by TAO_FlResource_Loader. + * This factory is intended for creating FlReactor for ORB. This + * factory can be feed into ORB using + * TAO_ORB_Core::set_gui_resource_factory method which is usually + * done by TAO_FlResource_Loader. */ + class TAO_FlResource_Export FlResource_Factory : public GUIResource_Factory { public: + FlResource_Factory (); + protected: + /// Create or obtain current reactor implementation virtual ACE_Reactor_Impl *reactor_impl (void); @@ -45,4 +52,4 @@ namespace TAO }; } #include /**/ "ace/post.h" -#endif /* _TAO_FLRESOURCE_FACTORY_H */ +#endif /* TAO_FLRESOURCE_FACTORY_H */ diff --git a/TAO/tao/FlResource_Loader.cpp b/TAO/tao/FlResource_Loader.cpp index b3dc6916c2f..13f01c7bef4 100644 --- a/TAO/tao/FlResource_Loader.cpp +++ b/TAO/tao/FlResource_Loader.cpp @@ -3,14 +3,21 @@ #include "ORB_Core.h" #include "FlResource_Factory.h" -ACE_RCSID(tao, FlResource_Loader, "$Id$"); +ACE_RCSID( TAO_FlResource, + FlResource_Loader, + "$Id$"); namespace TAO { FlResource_Loader::FlResource_Loader () { - TAO_ORB_Core::set_gui_resource_factory( new FlResource_Factory () ); + FlResource_Factory *tmp = 0; + + ACE_NEW (tmp, + FlResource_Factory ()); + + TAO_ORB_Core::set_gui_resource_factory( tmp ); } FlResource_Loader::~FlResource_Loader () diff --git a/TAO/tao/FlResource_Loader.h b/TAO/tao/FlResource_Loader.h index dc19f803a24..c56c2c5a39f 100644 --- a/TAO/tao/FlResource_Loader.h +++ b/TAO/tao/FlResource_Loader.h @@ -11,10 +11,10 @@ */ //============================================================================= -#ifndef _TAO_FLRESOURCE_LOADER_H -#define _TAO_FLRESOURCE_LOADER_H +#ifndef TAO_FLRESOURCE_LOADER_H +#define TAO_FLRESOURCE_LOADER_H #include /**/ "ace/pre.h" -#include "TAO_FlResource_Export.h" +#include "tao/TAO_FlResource_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -22,22 +22,29 @@ namespace TAO { - /** Loads TAO resources related with Fl. + + /** + * @class FlResource_Loader + * + * @brief Loads TAO resources related with Fl. * - * This class changes the default reactor implementation into ACE_FlReactor by - * calling TAO_ORB_Core::set_gui_resource_factory. Please notice, this class has - * to be created in the main Fl thread, because set_gui_resource_factory creates - * a variable in TSS. This way FlReactor is instantiated only in Fl event loop thread. + * This class changes the default reactor implementation into + * ACE_FlReactor one by calling TAO_ORB_Core::set_gui_resource_factory. + * User should create an instance of this class before ORB_init + * when the TAO server has has to be integrated within Fl event loop. * + * Please notice, this class has to be created in the main Fl thread, + * because set_gui_resource_factory creates a variable in TSS. This way + * FlReactor is instantiated only in Qt event loop thread. */ class TAO_FlResource_Export FlResource_Loader { public: FlResource_Loader ( ); - virtual ~FlResource_Loader (); + virtual ~FlResource_Loader (); }; } #include /**/ "ace/post.h" -#endif /* _TAO_FLRESOURCE_LOADER_H */ +#endif /* TAO_FLRESOURCE_LOADER_H */ diff --git a/TAO/tao/GUIResource_Factory.cpp b/TAO/tao/GUIResource_Factory.cpp index fc781b04f83..ae586a57a99 100644 --- a/TAO/tao/GUIResource_Factory.cpp +++ b/TAO/tao/GUIResource_Factory.cpp @@ -1,7 +1,7 @@ //$Id$ -#include /**/ "ace/Reactor.h" -#include /**/ "GUIResource_Factory.h" -#include /**/ "debug.h" +#include "tao/GUIResource_Factory.h" +#include "ace/Reactor.h" +#include "tao/debug.h" namespace TAO { @@ -17,6 +17,17 @@ namespace TAO ACE_Reactor * GUIResource_Factory::get_reactor (void) { + // @@Marek, do we need a lock here?? + // @Bala, I suppose we don't need locking for any + // reasonable use case as this + // factory is intended to be a variable in TSS. + // I can imagine that someone may try to use it in distinct + // threads, though I do not know + // what for. Nevertheless, just for a case I sync the creation of reactor. + // I think, that double checked locking is + // not necessary, because the performance is not an issue here. + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + ACE_Reactor *reactor = 0; ACE_NEW_RETURN (reactor, ACE_Reactor (this->reactor_impl (), 1), @@ -36,6 +47,8 @@ namespace TAO void GUIResource_Factory::reclaim_reactor (ACE_Reactor *reactor) { + ACE_GUARD ( TAO_SYNCH_MUTEX, ace_mon, this->lock_ ); + if (this->dynamically_allocated_reactor_ == 1) delete reactor; } diff --git a/TAO/tao/GUIResource_Factory.h b/TAO/tao/GUIResource_Factory.h index 192d4873d08..e10a3770497 100644 --- a/TAO/tao/GUIResource_Factory.h +++ b/TAO/tao/GUIResource_Factory.h @@ -6,15 +6,17 @@ * * $Id$ * - * @author Hamish Friedlander * @author Balachandran Natarajan + * @author Marek Brudka */ //============================================================================= #ifndef TAO_GUI_RESOURCE_FACTORY_H #define TAO_GUI_RESOURCE_FACTORY_H #include /**/ "ace/pre.h" -#include /**/ "TAO_Export.h" +#include "ace/Thread_Mutex.h" +#include "tao/TAO_Export.h" +#include "tao/orbconf.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -26,24 +28,23 @@ class ACE_Reactor; namespace TAO { - /** Abstract base class for the GUI resource factory, which will be held in TSS by the ORB Core. + /** Abstract base class for the GUI resource factory. * - * 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. + * 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. */ class TAO_Export GUIResource_Factory { public: + GUIResource_Factory (); - virtual ~GUIResource_Factory (); - /** Create or return current reactor instance. - * Please note that this call is NOT synchronized. Left to the - * higher level versions to synchronize access. - */ - virtual ACE_Reactor_Impl *reactor_impl (void) = 0; + virtual ~GUIResource_Factory (); /** Create ACE_Reactor using allocate_reactor_impl. * Please note that this call is NOT synchronized. Left to the @@ -57,7 +58,16 @@ namespace TAO */ virtual void reclaim_reactor (ACE_Reactor *); + protected: + + /** Create or return current reactor instance. + * Please note that this call is NOT synchronized. Left to the + * get_reactor to synchronize access. + */ + virtual ACE_Reactor_Impl *reactor_impl (void) = 0; + private: + /** * Flag that is set to 1 if the reactor obtained from the * get_reactor() method is dynamically allocated. If this flag is @@ -70,6 +80,9 @@ namespace TAO * override the reclaim_reactor() method. */ int dynamically_allocated_reactor_; + + /// for internal locking. + TAO_SYNCH_MUTEX lock_; }; } diff --git a/TAO/tao/QtResource_Factory.cpp b/TAO/tao/QtResource_Factory.cpp index dd61a937acf..561fffca095 100644 --- a/TAO/tao/QtResource_Factory.cpp +++ b/TAO/tao/QtResource_Factory.cpp @@ -4,9 +4,9 @@ #include "debug.h" #include "ace/QtReactor.h" -ACE_RCSID(TAO_QtResource, - QtResource_Factory, - "$Id$"); +ACE_RCSID( TAO_QtResource, + QtResource_Factory, + "$Id$"); namespace TAO { @@ -19,7 +19,7 @@ namespace TAO ACE_Reactor_Impl * QtResource_Factory::reactor_impl (void) - { + { // synchronized by external locks if (this->qapp_ == 0) { ACE_ERROR ((LM_ERROR, @@ -28,7 +28,6 @@ namespace TAO return 0; } - // @@Marek, do we need a lock here?? if (!this->reactor_impl_) { diff --git a/TAO/tao/QtResource_Factory.h b/TAO/tao/QtResource_Factory.h index 7fe55dd87ab..5e9b78bf60b 100644 --- a/TAO/tao/QtResource_Factory.h +++ b/TAO/tao/QtResource_Factory.h @@ -21,12 +21,16 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include +#include "ace/QtReactor.h" #include "tao/GUIResource_Factory.h" namespace TAO { - /** TAO_GUI_Resource_Factory for creating QtReactor. + /** + * @class QtResource_Factory + * + * @brief TAO_GUI_Resource_Factory for creating QtReactor. * * This factory is intended for creating QtReactor for ORB. This * factory can be feed into ORB using @@ -36,8 +40,11 @@ namespace TAO class TAO_QtResource_Export QtResource_Factory : public GUIResource_Factory { public: + QtResource_Factory (QApplication *qapp_); + protected: + /// Create or obtain current reactor implementation virtual ACE_Reactor_Impl *reactor_impl (void); @@ -48,6 +55,9 @@ namespace TAO /// QApplication running reactor QApplication *qapp_; + + /// for internal locking. + TAO_SYNCH_MUTEX lock_; }; } diff --git a/TAO/tao/QtResource_Loader.cpp b/TAO/tao/QtResource_Loader.cpp index 92ca04f29a2..70fdae3053c 100644 --- a/TAO/tao/QtResource_Loader.cpp +++ b/TAO/tao/QtResource_Loader.cpp @@ -3,7 +3,9 @@ #include "ORB_Core.h" #include "QtResource_Factory.h" -ACE_RCSID(tao, QtResource_Loader, "$Id$"); +ACE_RCSID( TAO_QtResource, + QtResource_Loader, + "$Id$"); namespace TAO { diff --git a/TAO/tao/QtResource_Loader.h b/TAO/tao/QtResource_Loader.h index 6d461084645..14a2e6d84b6 100644 --- a/TAO/tao/QtResource_Loader.h +++ b/TAO/tao/QtResource_Loader.h @@ -15,7 +15,7 @@ #define TAO_QTRESOURCE_LOADER_H #include /**/ "ace/pre.h" -#include "TAO_QtResource_Export.h" +#include "tao/TAO_QtResource_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -31,14 +31,13 @@ namespace TAO * @brief Loads TAO resources related with Qt. * * This class changes the default reactor implementation into - * ACE_QtReactor by calling - * TAO_ORB_Core::set_gui_resource_factory. Please notice, this class - * has to be created in the main Qt thread, because - * set_gui_resource_factory creates a variable in TSS. This way - * QtReactor is instantiated only in Qt event loop thread. + * ACE_QtReactor one by calling TAO_ORB_Core::set_gui_resource_factory. + * User should create an instance of this class before ORB_init + * when the TAO server has has to be integrated within Qt event loop. * - * @@Marek, could you please point out that this class is the - * interface to the user to load things + * Please notice, this class has to be created in the main Qt thread, + * because set_gui_resource_factory creates a variable in TSS. This way + * QtReactor is instantiated only in Qt event loop thread. */ class TAO_QtResource_Export QtResource_Loader @@ -50,4 +49,4 @@ namespace TAO }; } #include /**/ "ace/post.h" -#endif /* _TAO_QTRESOURCE_LOADER_H */ +#endif /* TAO_QTRESOURCE_LOADER_H */ diff --git a/TAO/tao/TkResource_Factory.cpp b/TAO/tao/TkResource_Factory.cpp index 4c1926bb246..765e7a40e02 100644 --- a/TAO/tao/TkResource_Factory.cpp +++ b/TAO/tao/TkResource_Factory.cpp @@ -1,10 +1,12 @@ //$Id$ -#include /**/ "TkResource_Factory.h" -#include /**/ "debug.h" -#include /**/ "ace/TkReactor.h" +#include "tao/TkResource_Factory.h" +#include "tao/debug.h" +#include "ace/TkReactor.h" -ACE_RCSID(tao, TkResource_Factory, "$Id$"); +ACE_RCSID( TAO_TkResource, + TkResource_Factory, + "$Id$"); namespace TAO @@ -18,6 +20,7 @@ namespace TAO ACE_Reactor_Impl * TkResource_Factory::reactor_impl (void) { + // synchronized by external locks if (!this->reactor_impl_) { ACE_NEW_RETURN (this->reactor_impl_, diff --git a/TAO/tao/TkResource_Factory.h b/TAO/tao/TkResource_Factory.h index d1d3f6d2a53..e08b436d274 100644 --- a/TAO/tao/TkResource_Factory.h +++ b/TAO/tao/TkResource_Factory.h @@ -10,12 +10,12 @@ * @author Marek Brudka */ //============================================================================= -#ifndef _TAO_TKRESOURCE_FACTORY_H -#define _TAO_TKRESOURCE_FACTORY_H +#ifndef TAO_TKRESOURCE_FACTORY_H +#define TAO_TKRESOURCE_FACTORY_H #include /**/ "ace/pre.h" -#include /**/ "ace/TkReactor.h" -#include /**/ "TAO_TkResource_Export.h" -#include /**/ "GUIResource_Factory.h" +#include "ace/TkReactor.h" +#include "tao/TAO_TkResource_Export.h" +#include "tao/GUIResource_Factory.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -24,18 +24,25 @@ namespace TAO { - /** TAO_GUI_Resource_Factory for creating TkReactor. + /** + * @class TkResource_Factory * - * This factory is intended for creating TkReactor for ORB. This factory can be - * feed into ORB using TAO_ORB_Core::set_gui_resource_factory method which is - * usually done by TAO_TkResource_Loader. + * @brief TAO_GUI_Resource_Factory for creating TkReactor. + * + * This factory is intended for creating TkReactor for ORB. This + * factory can be feed into ORB using + * TAO_ORB_Core::set_gui_resource_factory method which is usually + * done by TAO_TkResource_Loader. */ class TAO_TkResource_Export TkResource_Factory : public GUIResource_Factory { public: + TkResource_Factory (); + protected: + /// Create or obtain current reactor implementation virtual ACE_Reactor_Impl *reactor_impl (void); @@ -43,7 +50,10 @@ namespace TAO /// Reactor created by this factory. ACE_TkReactor *reactor_impl_; + + /// for internal locking. + TAO_SYNCH_MUTEX lock_; }; } #include /**/ "ace/post.h" -#endif /* _TAO_TKRESOURCE_FACTORY_H */ +#endif /* TAO_TKRESOURCE_FACTORY_H */ diff --git a/TAO/tao/TkResource_Loader.cpp b/TAO/tao/TkResource_Loader.cpp index 3d79b3735d5..782fbc92bf0 100644 --- a/TAO/tao/TkResource_Loader.cpp +++ b/TAO/tao/TkResource_Loader.cpp @@ -3,14 +3,21 @@ #include "ORB_Core.h" #include "TkResource_Factory.h" -ACE_RCSID(tao, TkResource_Loader, "$Id$"); +ACE_RCSID( TAO_TkResource, + TkResource_Loader, + "$Id$"); namespace TAO { TkResource_Loader::TkResource_Loader () { - TAO_ORB_Core::set_gui_resource_factory( new TkResource_Factory () ); + TkResource_Factory *tmp = 0; + + ACE_NEW (tmp, + TkResource_Factory ()); + + TAO_ORB_Core::set_gui_resource_factory( tmp ); } TkResource_Loader::~TkResource_Loader () diff --git a/TAO/tao/TkResource_Loader.h b/TAO/tao/TkResource_Loader.h index 6489c513868..9b20a5eac02 100644 --- a/TAO/tao/TkResource_Loader.h +++ b/TAO/tao/TkResource_Loader.h @@ -11,10 +11,10 @@ */ //============================================================================= -#ifndef _TAO_TKRESOURCE_LOADER_H -#define _TAO_TKRESOURCE_LOADER_H +#ifndef TAO_TKRESOURCE_LOADER_H +#define TAO_TKRESOURCE_LOADER_H #include /**/ "ace/pre.h" -#include /**/ "TAO_TkResource_Export.h" +#include "tao/TAO_TkResource_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -22,22 +22,28 @@ namespace TAO { - /** Loads TAO resources related with Tk. + /** + * @class TkResource_Loader * - * This class changes the default reactor implementation into ACE_TkReactor by - * calling TAO_ORB_Core::set_gui_resource_factory. Please notice, this class has - * to be created in the main Tk thread, because set_gui_resource_factory creates - * a variable in TSS. This way TkReactor is instantiated only in Tk event loop thread. + * @brief Loads TAO resources related with Tk. * + * This class changes the default reactor implementation into + * ACE_TkReactor one by calling TAO_ORB_Core::set_gui_resource_factory. + * User should create an instance of this class before ORB_init + * when the TAO server has has to be integrated within Tk event loop. + * + * Please notice, this class has to be created in the main Tk thread, + * because set_gui_resource_factory creates a variable in TSS. This way + * TkReactor is instantiated only in Tk event loop thread. */ class TAO_TkResource_Export TkResource_Loader { public: TkResource_Loader ( ); - virtual ~TkResource_Loader (); + virtual ~TkResource_Loader (); }; } #include /**/ "ace/post.h" -#endif /* _TAO_TKRESOURCE_LOADER_H */ +#endif /* TAO_TKRESOURCE_LOADER_H */ diff --git a/TAO/tao/XtResource_Factory.cpp b/TAO/tao/XtResource_Factory.cpp index 3c5d2e393e9..5ca19fba0f0 100644 --- a/TAO/tao/XtResource_Factory.cpp +++ b/TAO/tao/XtResource_Factory.cpp @@ -1,10 +1,12 @@ //$Id$ -#include /**/ "XtResource_Factory.h" -#include /**/ "debug.h" -#include /**/ "ace/XtReactor.h" +#include "XtResource_Factory.h" +#include "debug.h" +#include "ace/XtReactor.h" -ACE_RCSID(tao, XtResource_Factory, "$Id$"); +ACE_RCSID( TAO_XtResource, + XtResource_Factory, + "$Id$"); namespace TAO { @@ -18,10 +20,12 @@ namespace TAO ACE_Reactor_Impl * XtResource_Factory::reactor_impl (void) { + // synchronized by external locks if (this->context_ == 0) { ACE_ERROR ((LM_ERROR, - "TAO (%P|%t) - XtAppContext is undefined. Cannot create ACE_XtReactor \n")); + ACE_TEXT("TAO (%P|%t) - XtAppContext is undefined.") + ACE_TEXT(" Cannot create ACE_XtReactor \n"))); return 0; } diff --git a/TAO/tao/XtResource_Factory.h b/TAO/tao/XtResource_Factory.h index 051429485b9..5498865a256 100644 --- a/TAO/tao/XtResource_Factory.h +++ b/TAO/tao/XtResource_Factory.h @@ -13,17 +13,15 @@ #ifndef TAO_XTRESOURCE_FACTORY_H #define TAO_XTRESOURCE_FACTORY_H #include /**/ "ace/pre.h" - -#include "TAO_XtResource_Export.h" - +#include /**/ +#include "tao/TAO_XtResource_Export.h" +#include "ace/XtReactor.h" +#include "tao/GUIResource_Factory.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/XtReactor.h" -#include "tao/GUIResource_Factory.h" - namespace TAO { @@ -37,6 +35,7 @@ namespace TAO * TAO_ORB_Core::set_gui_resource_factory method which is usually * done by TAO_XtResource_Loader. */ + class TAO_XtResource_Export XtResource_Factory : public GUIResource_Factory { public: @@ -52,6 +51,9 @@ namespace TAO /// Xt context for XtReactor XtAppContext context_; + + /// for internal locking + TAO_SYNCH_MUTEX lock_; }; } diff --git a/TAO/tao/XtResource_Loader.cpp b/TAO/tao/XtResource_Loader.cpp index 3127ffffc20..d2350ddcc00 100644 --- a/TAO/tao/XtResource_Loader.cpp +++ b/TAO/tao/XtResource_Loader.cpp @@ -3,14 +3,21 @@ #include "ORB_Core.h" #include "XtResource_Factory.h" -ACE_RCSID(tao, XtResource_Loader, "$Id$"); +ACE_RCSID( TAO_XtResource, + XtResource_Loader, + "$Id$"); namespace TAO { XtResource_Loader::XtResource_Loader (XtAppContext context) { - TAO_ORB_Core::set_gui_resource_factory( new XtResource_Factory (context) ); + XtResource_Factory *tmp = 0; + + ACE_NEW (tmp, + XtResource_Factory (context)); + + TAO_ORB_Core::set_gui_resource_factory( tmp ); } XtResource_Loader::~XtResource_Loader () diff --git a/TAO/tao/XtResource_Loader.h b/TAO/tao/XtResource_Loader.h index 6641be0d314..f3e809ab1ed 100644 --- a/TAO/tao/XtResource_Loader.h +++ b/TAO/tao/XtResource_Loader.h @@ -11,11 +11,11 @@ */ //============================================================================= -#ifndef _TAO_XTRESOURCE_LOADER_H -#define _TAO_XTRESOURCE_LOADER_H +#ifndef TAO_XTRESOURCE_LOADER_H +#define TAO_XTRESOURCE_LOADER_H #include /**/ "ace/pre.h" -#include /**/ "TAO_XtResource_Export.h" #include /**/ +#include "tao/TAO_XtResource_Export.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -23,22 +23,28 @@ namespace TAO { - /** Loads TAO resources related with Xt. + /** + * @class XtResource_Loader * - * This class changes the default reactor implementation into ACE_XtReactor by - * calling TAO_ORB_Core::set_gui_resource_factory. Please notice, this class has - * to be created in the main Xt thread, because set_gui_resource_factory creates - * a variable in TSS. This way XtReactor is instantiated only in Xt event loop thread. + * @brief Loads TAO resources related with Xt. * + * This class changes the default reactor implementation into + * ACE_XtReactor one by calling TAO_ORB_Core::set_gui_resource_factory. + * User should create an instance of this class before ORB_init + * when the TAO server has has to be integrated within Xt event loop. + * + * Please notice, this class has to be created in the main Xt thread, + * because set_gui_resource_factory creates a variable in TSS. This way + * XtReactor is instantiated only in Xt event loop thread. */ class TAO_XtResource_Export XtResource_Loader { public: XtResource_Loader (XtAppContext context); - virtual ~XtResource_Loader (); + virtual ~XtResource_Loader (); }; } #include /**/ "ace/post.h" -#endif /* _TAO_XTRESOURCE_LOADER_H */ +#endif /* TAO_XTRESOURCE_LOADER_H */ -- cgit v1.2.1