diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-09 02:13:23 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-09 02:13:23 +0000 |
commit | 7256691a6bef2fe044e44ce661a32287d0a6f7e6 (patch) | |
tree | 980f22cdd387d6596b6d7ca9da19684ec91a6f46 /TAO/tao/params.i | |
parent | 5db2130b5d4fcb795b0b8aa76e6be673f94817e8 (diff) | |
download | ATCD-7256691a6bef2fe044e44ce661a32287d0a6f7e6.tar.gz |
Changed TAO_OA_PARAMS to not be a ACE_Singleton class but instead just a
non-templated singleton class.
Diffstat (limited to 'TAO/tao/params.i')
-rw-r--r-- | TAO/tao/params.i | 72 |
1 files changed, 70 insertions, 2 deletions
diff --git a/TAO/tao/params.i b/TAO/tao/params.i index d5bd8f53f31..194490b38aa 100644 --- a/TAO/tao/params.i +++ b/TAO/tao/params.i @@ -99,8 +99,8 @@ TAO_OA_Parameters::demux_strategy (DEMUX_STRATEGY strategy) this->demux_ = strategy; // Trust that the value is valid! } -ACE_INLINE -void TAO_OA_Parameters::demux_strategy (const char* strategy) +ACE_INLINE void +TAO_OA_Parameters::demux_strategy (const char* strategy) { // Determine the demux strategy based on the given name if (!ACE_OS::strcmp (strategy, "linear")) @@ -144,4 +144,72 @@ TAO_OA_Parameters::tablesize (void) return this->tablesize_; } +ACE_INLINE TAO_OA_Parameters *& +TAO_OA_Parameters::instance_i (void) +{ +#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + // Pointer to the Singleton instance. This works around a bug with + // G++... + static TAO_OA_Parameters *instance_ = 0; + + return instance_; +#else + return TAO_OA_Parameters::instance_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +} + +ACE_INLINE ACE_SYNCH_MUTEX & +TAO_OA_Parameters::singleton_lock_i (void) +{ +#if defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) + // ACE_SYNCH_MUTEX the creation of the singleton. This works around a + // "feature" of G++... ;-) + static ACE_SYNCH_MUTEX ace_singleton_lock_; + + return ace_singleton_lock_; +#else + return TAO_OA_Parameters::ace_singleton_lock_; +#endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ +} + +ACE_INLINE TAO_OA_Parameters * +TAO_OA_Parameters::instance (void) +{ + ACE_TRACE ("TAO_OA_Parameters::instance"); + + TAO_OA_Parameters *&singleton = TAO_OA_Parameters::instance_i (); + + // Perform the Double-Check pattern... + if (singleton == 0) + { + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, (TAO_OA_Parameters::singleton_lock_i ()), 0); + + if (singleton == 0) + ACE_NEW_RETURN (singleton, TAO_OA_Parameters, 0); + } + + return singleton; +} + +ACE_INLINE TAO_OA_Parameters * +TAO_OA_Parameters::instance (TAO_OA_Parameters *new_instance) +{ + ACE_TRACE ("TAO_OA_Parameters::set_instance"); + + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, (TAO_OA_Parameters::singleton_lock_i ()), 0); + + TAO_OA_Parameters *&singleton = TAO_OA_Parameters::instance_i (); + TAO_OA_Parameters *old_instance = singleton; + singleton = new_instance; + + return old_instance; +} + + +#if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) +// Pointer to the Singleton instance. +TAO_OA_Parameters *TAO_OA_Parameters::instance_ = 0; +// Lock the creation of the singleton. +ACE_SYNCH_MUTEX TAO_OA_Parameters::ace_singleton_lock_; +#endif /* !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) */ |