[Libreoffice-commits] core.git: 2 commits - framework/inc framework/source

Stephan Bergmann sbergman at redhat.com
Thu Mar 20 07:30:05 PDT 2014


 framework/inc/classes/propertysethelper.hxx         |    1 
 framework/inc/threadhelp/threadhelpbase.hxx         |   66 ---------------
 framework/source/accelerators/storageholder.cxx     |   84 +++++---------------
 framework/source/inc/accelerators/storageholder.hxx |    4 
 4 files changed, 24 insertions(+), 131 deletions(-)

New commits:
commit 03fc5edba3f34c63315daebd08ae2888bf5332b2
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Mar 20 12:02:51 2014 +0100

    Remove newly unused framework::ThreadHelpBase
    
    Change-Id: I75e7cfc8aa1f4e4e50a2e21c5f7596363594e179

diff --git a/framework/inc/classes/propertysethelper.hxx b/framework/inc/classes/propertysethelper.hxx
index d8baf70..0be92aa 100644
--- a/framework/inc/classes/propertysethelper.hxx
+++ b/framework/inc/classes/propertysethelper.hxx
@@ -20,7 +20,6 @@
 #ifndef INCLUDED_FRAMEWORK_INC_CLASSES_PROPERTYSETHELPER_HXX
 #define INCLUDED_FRAMEWORK_INC_CLASSES_PROPERTYSETHELPER_HXX
 
-#include <threadhelp/threadhelpbase.hxx>
 #include <threadhelp/transactionbase.hxx>
 #include <general.h>
 #include <stdtypes.h>
diff --git a/framework/inc/threadhelp/threadhelpbase.hxx b/framework/inc/threadhelp/threadhelpbase.hxx
deleted file mode 100644
index 4ac22bf..0000000
--- a/framework/inc/threadhelp/threadhelpbase.hxx
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_FRAMEWORK_INC_THREADHELP_THREADHELPBASE_HXX
-#define INCLUDED_FRAMEWORK_INC_THREADHELP_THREADHELPBASE_HXX
-
-#include <threadhelp/lockhelper.hxx>
-
-namespace framework{
-
-/*-************************************************************************************************************
-    @short          "baseclass" to make own classes threadsafe
-    @descr          Sometimes you must share your lock- or mutex member with any other baseclasses.
-                    And baseclasses are initialized erlier then members! That's why you should use
-                    this struct as first of your baseclasses!!!
-                    Then you will get a public member "m_aLock" which can be used by special guard implementations
-                    to make your code threadsafe.
-
-    @seealso        class LockHelper
-
-    @implements     -
-    @base           -
-
-    @devstatus      ready to use
-*//*-*************************************************************************************************************/
-struct ThreadHelpBase
-{
-
-    //  public methods
-
-    public:
-        ThreadHelpBase( comphelper::SolarMutex* pSolarMutex = NULL )
-                :   m_aLock( pSolarMutex )
-        {
-        }
-
-
-    //  public member
-    //  Make it mutable for using in const functions!
-
-    public:
-
-        mutable LockHelper m_aLock;
-};
-
-}       //  namespace framework
-
-#endif // INCLUDED_FRAMEWORK_INC_THREADHELP_THREADHELPBASE_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit c641f300f09ec0e520846b09e12bf8041299a6cf
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Mar 20 15:14:42 2014 +0100

    Use an osl::Mutex directly
    
    Change-Id: If8ff4fc256e530f6b79cc97cf1f47880c93864bf

diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx
index 0522770..b19d3e0 100644
--- a/framework/source/accelerators/storageholder.cxx
+++ b/framework/source/accelerators/storageholder.cxx
@@ -19,7 +19,6 @@
 
 #include <accelerators/storageholder.hxx>
 
-#include <threadhelp/guard.hxx>
 #include <services.h>
 
 #include <com/sun/star/container/NoSuchElementException.hpp>
@@ -49,7 +48,6 @@ namespace framework
 
 
 StorageHolder::StorageHolder()
-    : ThreadHelpBase(                                        )
 {
 }
 
@@ -63,9 +61,7 @@ StorageHolder::~StorageHolder()
 
 void StorageHolder::forgetCachedStorages()
 {
-    // SAFE -> ----------------------------------
-    Guard aWriteLock(m_aLock);
-
+    osl::MutexGuard g(m_mutex);
     TPath2StorageInfo::iterator pIt;
     for (  pIt  = m_lStorages.begin();
            pIt != m_lStorages.end()  ;
@@ -76,28 +72,20 @@ void StorageHolder::forgetCachedStorages()
         rInfo.Storage.clear();
     }
     m_lStorages.clear();
-
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
 }
 
 
 void StorageHolder::setRootStorage(const css::uno::Reference< css::embed::XStorage >& xRoot)
 {
-    // SAFE -> ----------------------------------
-    Guard aWriteLock(m_aLock);
+    osl::MutexGuard g(m_mutex);
     m_xRoot = xRoot;
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
 }
 
 
 css::uno::Reference< css::embed::XStorage > StorageHolder::getRootStorage() const
 {
-    // SAFE -> ----------------------------------
-    Guard aReadLock(m_aLock);
+    osl::MutexGuard g(m_mutex);
     return m_xRoot;
-    // <- SAFE ----------------------------------
 }
 
 
@@ -108,9 +96,9 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri
     OUStringList    lFolders    = StorageHolder::impl_st_parsePath(sNormedPath);
 
     // SAFE -> ----------------------------------
-    Guard aReadLock(m_aLock);
+    osl::ResettableMutexGuard aReadLock(m_mutex);
     css::uno::Reference< css::embed::XStorage > xParent = m_xRoot;
-    aReadLock.unlock();
+    aReadLock.clear();
     // <- SAFE ----------------------------------
 
     css::uno::Reference< css::embed::XStorage > xChild  ;
@@ -127,7 +115,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri
                                sCheckPath += PATH_SEPARATOR;
 
         // SAFE -> ------------------------------
-        aReadLock.lock();
+        aReadLock.reset();
 
         // If we found an already open storage ... we must increase
         // its use count. Otherwhise it will may be closed to early :-)
@@ -138,10 +126,13 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri
             pInfo = &(pCheck->second);
             ++(pInfo->UseCount);
             xChild = pInfo->Storage;
+
+            aReadLock.clear();
+            // <- SAFE ------------------------------
         }
         else
         {
-            aReadLock.unlock();
+            aReadLock.clear();
             // <- SAFE ------------------------------
 
             try
@@ -165,13 +156,10 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::openPath(const OUStri
                     throw;
                 }
 
-            // SAFE -> ------------------------------
-            Guard aWriteLock(m_aLock);
+            osl::MutexGuard g(m_mutex);
             pInfo = &(m_lStorages[sCheckPath]);
             pInfo->Storage  = xChild;
             pInfo->UseCount = 1;
-            aWriteLock.unlock();
-            // <- SAFE ------------------------------
         }
 
         xParent   = xChild;
@@ -195,8 +183,7 @@ StorageHolder::TStorageList StorageHolder::getAllPathStorages(const OUString& sP
     OUString              sRelPath       ;
     OUStringList::const_iterator pIt            ;
 
-    // SAFE -> ----------------------------------
-    Guard aReadLock(m_aLock);
+    osl::MutexGuard g(m_mutex);
 
     for (  pIt  = lFolders.begin();
            pIt != lFolders.end()  ;
@@ -223,9 +210,6 @@ StorageHolder::TStorageList StorageHolder::getAllPathStorages(const OUString& sP
         sRelPath += PATH_SEPARATOR;
     }
 
-    aReadLock.unlock();
-    // <- SAFE ----------------------------------
-
     return lStoragesOfPath;
 }
 
@@ -247,9 +231,9 @@ void StorageHolder::commitPath(const OUString& sPath)
     }
 
     // SAFE -> ------------------------------
-    Guard aReadLock(m_aLock);
+    osl::ClearableMutexGuard aReadLock(m_mutex);
     xCommit = css::uno::Reference< css::embed::XTransactedObject >(m_xRoot, css::uno::UNO_QUERY);
-    aReadLock.unlock();
+    aReadLock.clear();
     // <- SAFE ------------------------------
 
     if (xCommit.is())
@@ -280,8 +264,7 @@ void StorageHolder::closePath(const OUString& rPath)
         sParentPath = sCurrentRelPath;
     }
 
-    // SAFE -> ------------------------------
-    Guard aReadLock(m_aLock);
+    osl::MutexGuard g(m_mutex);
 
     OUStringList::reverse_iterator pIt2;
     for (  pIt2  = lFolders.rbegin();
@@ -301,9 +284,6 @@ void StorageHolder::closePath(const OUString& rPath)
             m_lStorages.erase(pPath);
         }
     }
-
-    aReadLock.unlock();
-    // <- SAFE ------------------------------
 }
 
 
@@ -311,8 +291,7 @@ void StorageHolder::notifyPath(const OUString& sPath)
 {
     OUString sNormedPath = StorageHolder::impl_st_normPath(sPath);
 
-    // SAFE -> ------------------------------
-    Guard aReadLock(m_aLock);
+    osl::MutexGuard g(m_mutex);
 
     TPath2StorageInfo::iterator pIt1 = m_lStorages.find(sNormedPath);
     if (pIt1 == m_lStorages.end())
@@ -328,9 +307,6 @@ void StorageHolder::notifyPath(const OUString& sPath)
         if (pListener)
             pListener->changesOccurred(sNormedPath);
     }
-
-    aReadLock.unlock();
-    // <- SAFE ------------------------------
 }
 
 
@@ -339,8 +315,7 @@ void StorageHolder::addStorageListener(      IStorageListener* pListener,
 {
     OUString sNormedPath = StorageHolder::impl_st_normPath(sPath);
 
-    // SAFE -> ------------------------------
-    Guard aReadLock(m_aLock);
+    osl::MutexGuard g(m_mutex);
 
     TPath2StorageInfo::iterator pIt1 = m_lStorages.find(sNormedPath);
     if (pIt1 == m_lStorages.end())
@@ -350,9 +325,6 @@ void StorageHolder::addStorageListener(      IStorageListener* pListener,
     TStorageListenerList::iterator pIt2 = ::std::find(rInfo.Listener.begin(), rInfo.Listener.end(), pListener);
     if (pIt2 == rInfo.Listener.end())
         rInfo.Listener.push_back(pListener);
-
-    aReadLock.unlock();
-    // <- SAFE ------------------------------
 }
 
 
@@ -361,8 +333,7 @@ void StorageHolder::removeStorageListener(      IStorageListener* pListener,
 {
     OUString sNormedPath = StorageHolder::impl_st_normPath(sPath);
 
-    // SAFE -> ------------------------------
-    Guard aReadLock(m_aLock);
+    osl::MutexGuard g(m_mutex);
 
     TPath2StorageInfo::iterator pIt1 = m_lStorages.find(sNormedPath);
     if (pIt1 == m_lStorages.end())
@@ -372,16 +343,12 @@ void StorageHolder::removeStorageListener(      IStorageListener* pListener,
     TStorageListenerList::iterator pIt2 = ::std::find(rInfo.Listener.begin(), rInfo.Listener.end(), pListener);
     if (pIt2 != rInfo.Listener.end())
         rInfo.Listener.erase(pIt2);
-
-    aReadLock.unlock();
-    // <- SAFE ------------------------------
 }
 
 
 OUString StorageHolder::getPathOfStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
 {
-    // SAFE -> ------------------------------
-    Guard aReadLock(m_aLock);
+    osl::MutexGuard g(m_mutex);
 
     TPath2StorageInfo::const_iterator pIt;
     for (  pIt  = m_lStorages.begin();
@@ -397,8 +364,6 @@ OUString StorageHolder::getPathOfStorage(const css::uno::Reference< css::embed::
         return OUString();
 
     return pIt->first;
-
-    // <- SAFE ------------------------------
 }
 
 
@@ -425,7 +390,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::getParentStorage(cons
         return css::uno::Reference< css::embed::XStorage >();
 
     // SAFE -> ----------------------------------
-    Guard aReadLock(m_aLock);
+    osl::ClearableMutexGuard aReadLock(m_mutex);
 
     // b)
     if (c < 2)
@@ -444,7 +409,7 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::getParentStorage(cons
     if (pParent != m_lStorages.end())
         return pParent->second.Storage;
 
-    aReadLock.unlock();
+    aReadLock.clear();
     // <- SAFE ----------------------------------
 
     // ?
@@ -455,14 +420,9 @@ css::uno::Reference< css::embed::XStorage > StorageHolder::getParentStorage(cons
 
 void StorageHolder::operator=(const StorageHolder& rCopy)
 {
-    // SAFE -> ----------------------------------
-    Guard aWriteLock(m_aLock);
-
+    osl::MutexGuard g(m_mutex);
     m_xRoot     = rCopy.m_xRoot;
     m_lStorages = rCopy.m_lStorages;
-
-    aWriteLock.unlock();
-    // <- SAFE ----------------------------------
 }
 
 
diff --git a/framework/source/inc/accelerators/storageholder.hxx b/framework/source/inc/accelerators/storageholder.hxx
index 8879e03..07c0b11 100644
--- a/framework/source/inc/accelerators/storageholder.hxx
+++ b/framework/source/inc/accelerators/storageholder.hxx
@@ -21,7 +21,6 @@
 #define INCLUDED_FRAMEWORK_SOURCE_INC_ACCELERATORS_STORAGEHOLDER_HXX
 
 #include <accelerators/istoragelistener.hxx>
-#include <threadhelp/threadhelpbase.hxx>
 #include <general.h>
 #include <stdtypes.h>
 
@@ -36,7 +35,7 @@ namespace framework
 /**
     TODO document me
  */
-class StorageHolder : private ThreadHelpBase // attention! Must be the first base class to guarentee right initialize lock ...
+class StorageHolder
 {
 
     // types
@@ -68,6 +67,7 @@ class StorageHolder : private ThreadHelpBase // attention! Must be the first bas
 
     // member
     private:
+        mutable osl::Mutex m_mutex;
 
         /** @short  TODO */
         css::uno::Reference< css::embed::XStorage > m_xRoot;


More information about the Libreoffice-commits mailing list