summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-11-04 12:48:59 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-11-04 11:49:42 +0100
commita2058e7516a01167c2d20ed157500b38db967c64 (patch)
tree375dc0fd109e36bc490ee7e04d2201cee10e4cf2 /avmedia
parentb156ca6e4692c2a32f41b9dfcd543966efc64a5d (diff)
replace double-checked locking patterns with thread safe local statics
Change-Id: Ie1aae7ecbd065a88b371d8c0deb586f54f7eff65 Reviewed-on: https://gerrit.libreoffice.org/62835 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/source/framework/soundhandler.cxx35
1 files changed, 8 insertions, 27 deletions
diff --git a/avmedia/source/framework/soundhandler.cxx b/avmedia/source/framework/soundhandler.cxx
index 70ed2f53c2dc..b004f7b52403 100644
--- a/avmedia/source/framework/soundhandler.cxx
+++ b/avmedia/source/framework/soundhandler.cxx
@@ -76,33 +76,14 @@ css::uno::Sequence< sal_Int8 > SAL_CALL SoundHandler::getImplementationId()
css::uno::Sequence< css::uno::Type > SAL_CALL SoundHandler::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 ... */
- static ::cppu::OTypeCollection aTypeCollection
- (
- cppu::UnoType<css::lang::XTypeProvider>::get(),
- cppu::UnoType<css::lang::XServiceInfo>::get(),
- cppu::UnoType<css::frame::XNotifyingDispatch>::get(),
- cppu::UnoType<css::frame::XDispatch>::get(),
- cppu::UnoType<css::document::XExtendedFilterDetection>::get()
- );
- /* ... and set his address to static pointer! */
- pTypeCollection = &aTypeCollection ;
- }
- }
- return pTypeCollection->getTypes();
+ static ::cppu::OTypeCollection aTypeCollection(
+ cppu::UnoType<css::lang::XTypeProvider>::get(),
+ cppu::UnoType<css::lang::XServiceInfo>::get(),
+ cppu::UnoType<css::frame::XNotifyingDispatch>::get(),
+ cppu::UnoType<css::frame::XDispatch>::get(),
+ cppu::UnoType<css::document::XExtendedFilterDetection>::get());
+
+ return aTypeCollection.getTypes();
}
#define IMPLEMENTATIONNAME_SOUNDHANDLER OUString("com.sun.star.comp.framework.SoundHandler")