diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-06-07 19:42:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-08 09:01:42 +0200 |
commit | e4f6840d0968ff9ea8976fdd735e1ecfe266cdde (patch) | |
tree | b6c45864f12504ef1da180a38ebb0872c52d268b /framework/inc | |
parent | 93d6a7ca515909c657224cb2f8d5397c376b8017 (diff) |
framework: replace double checked locking patterns
with thread safe local statics.
Change-Id: I660f6a899d1821bab627ed4972c4fc0d40610de2
Reviewed-on: https://gerrit.libreoffice.org/38541
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework/inc')
-rw-r--r-- | framework/inc/macros/xtypeprovider.hxx | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/framework/inc/macros/xtypeprovider.hxx b/framework/inc/macros/xtypeprovider.hxx index 473e7704869d..27f9a0546b93 100644 --- a/framework/inc/macros/xtypeprovider.hxx +++ b/framework/inc/macros/xtypeprovider.hxx @@ -25,7 +25,6 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Type.hxx> #include <cppuhelper/typeprovider.hxx> -#include <osl/mutex.hxx> namespace framework{ @@ -73,31 +72,13 @@ ________________________________________________________________________________ // private // complete implementation of XTypeProvider with max. 12 interfaces! -#define PRIVATE_DEFINE_XTYPEPROVIDER( CLASS, TYPES ) \ - PRIVATE_DEFINE_XTYPEPROVIDER_GETIMPLEMENTATIONID( CLASS ) \ +#define PRIVATE_DEFINE_XTYPEPROVIDER( CLASS, TYPES ) \ + PRIVATE_DEFINE_XTYPEPROVIDER_GETIMPLEMENTATIONID( CLASS ) \ css::uno::Sequence< css::uno::Type > SAL_CALL CLASS::getTypes() \ - { \ - /* Optimize this method ! */ \ - /* We initialize a static variable only one time. */ \ - /* And we don't must use a mutex at every call! */ \ - /* For the first call; pTypeCollection is NULL - */ \ - /* for the second call pTypeCollection is different from NULL! */ \ - static ::cppu::OTypeCollection* pTypeCollection = nullptr; \ - if ( pTypeCollection == nullptr ) \ - { \ - /* Ready for multithreading; get global mutex for first call of this method only! see before */ \ - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); \ - /* Control these pointer again ... it can be, that another instance will be faster then these! */ \ - if ( pTypeCollection == nullptr ) \ - { \ - /* Create a static typecollection ... */ \ - /* Attention: "TYPES" will expand to "(...)"! */ \ - static ::cppu::OTypeCollection aTypeCollection TYPES; \ - /* ... and set his address to static pointer! */ \ - pTypeCollection = &aTypeCollection; \ - } \ - } \ - return pTypeCollection->getTypes(); \ + { \ + /* Attention: "TYPES" will expand to "(...)"! */ \ + static cppu::OTypeCollection ourTypeCollection TYPES; \ + return ourTypeCollection.getTypes(); \ } // public |