diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-11-14 16:37:41 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-14 21:05:11 +0100 |
commit | 864cbd8b2216c043db42351beac3538b4d51adcd (patch) | |
tree | 3cadca3d4f97d7aa2b359a1226a3e7ff255f4761 /sal | |
parent | c77a881ee3d9846376f9544c15acbba083cda3be (diff) |
rtl::Static->thread-safe static in sal
Change-Id: I04f8a05aaa078642ee5e55c777b9b259c089695b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125197
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/alloc_fini.cxx | 29 | ||||
-rw-r--r-- | sal/rtl/bootstrap.cxx | 10 |
2 files changed, 24 insertions, 15 deletions
diff --git a/sal/rtl/alloc_fini.cxx b/sal/rtl/alloc_fini.cxx index 3745e900c86d..ba798452dedf 100644 --- a/sal/rtl/alloc_fini.cxx +++ b/sal/rtl/alloc_fini.cxx @@ -17,8 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <rtl/instance.hxx> - #include <rtllifecycle.h> namespace @@ -34,13 +32,16 @@ namespace rtl_cache_fini(); } }; - class theCacheSingleton - : public rtl::Static<rtlCacheSingleton, theCacheSingleton>{}; + rtlCacheSingleton& theCacheSingleton() + { + static rtlCacheSingleton SINGLETON; + return SINGLETON; + } } void ensureCacheSingleton() { - theCacheSingleton::get(); + theCacheSingleton(); } namespace @@ -56,13 +57,16 @@ namespace rtl_arena_fini(); } }; - class theArenaSingleton - : public rtl::Static<rtlArenaSingleton, theArenaSingleton>{}; + rtlArenaSingleton& theArenaSingleton() + { + static rtlArenaSingleton SINGLETON; + return SINGLETON; + } } void ensureArenaSingleton() { - theArenaSingleton::get(); + theArenaSingleton(); } namespace @@ -78,13 +82,16 @@ namespace rtl_locale_fini(); } }; - class theLocaleSingleton - : public rtl::Static<rtlLocaleSingleton, theLocaleSingleton>{}; + rtlLocaleSingleton& theLocaleSingleton() + { + static rtlLocaleSingleton SINGLETON; + return SINGLETON; + } } void ensureLocaleSingleton() { - theLocaleSingleton::get(); + theLocaleSingleton(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx index 9feadf874e54..e651a8436363 100644 --- a/sal/rtl/bootstrap.cxx +++ b/sal/rtl/bootstrap.cxx @@ -33,7 +33,6 @@ #include <rtl/ustrbuf.hxx> #include <rtl/ustring.hxx> #include <rtl/byteseq.hxx> -#include <rtl/instance.hxx> #include <rtl/malformeduriexception.hxx> #include <rtl/uri.hxx> #include <sal/log.hxx> @@ -407,8 +406,11 @@ struct FundamentalIniData FundamentalIniData& operator=(const FundamentalIniData&) = delete; }; -struct FundamentalIni: public rtl::Static< FundamentalIniData, FundamentalIni > -{}; +FundamentalIniData& FundamentalIni() +{ + static FundamentalIniData SINGLETON; + return SINGLETON; +} } @@ -511,7 +513,7 @@ bool Bootstrap_Impl::getValue( if (mode == LOOKUP_MODE_NORMAL) { - FundamentalIniData const & d = FundamentalIni::get(); + FundamentalIniData const & d = FundamentalIni(); Bootstrap_Impl const * b = static_cast<Bootstrap_Impl const *>(d.ini); if (b != nullptr && b != this && b->getDirectValue(key, value, mode, requestStack)) return true; |