diff options
Diffstat (limited to 'chart2/source/inc/LifeTime.hxx')
-rw-r--r-- | chart2/source/inc/LifeTime.hxx | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/chart2/source/inc/LifeTime.hxx b/chart2/source/inc/LifeTime.hxx index ca1e583f9835..582d10086b78 100644 --- a/chart2/source/inc/LifeTime.hxx +++ b/chart2/source/inc/LifeTime.hxx @@ -16,27 +16,29 @@ * 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_CHART2_SOURCE_INC_LIFETIME_HXX -#define INCLUDED_CHART2_SOURCE_INC_LIFETIME_HXX +#pragma once -#include <osl/mutex.hxx> +#include <config_options.h> +#include <mutex> #include <osl/conditn.hxx> -#include <cppuhelper/interfacecontainer.h> +#include <comphelper/interfacecontainer4.hxx> #include "charttoolsdllapi.hxx" +namespace com::sun::star::document { class XStorageChangeListener; } namespace com::sun::star::lang { class XComponent; } +namespace com::sun::star::lang { class XEventListener; } namespace com::sun::star::util { class CloseVetoException; } namespace com::sun::star::util { class XCloseListener; } namespace com::sun::star::util { class XCloseable; } +namespace com::sun::star::util { class XModifyListener; } +namespace com::sun::star::view { class XSelectionChangeListener; } namespace apphelper { -class OOO_DLLPUBLIC_CHARTTOOLS LifeTimeManager +class UNLESS_MERGELIBS(OOO_DLLPUBLIC_CHARTTOOLS) LifeTimeManager { friend class LifeTimeGuard; -protected: - mutable ::osl::Mutex m_aAccessMutex; public: LifeTimeManager( css::lang::XComponent* pComponent ); virtual ~LifeTimeManager(); @@ -45,25 +47,25 @@ public: /// @throws css::uno::RuntimeException bool dispose(); -public: - ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; + mutable std::mutex m_aAccessMutex; + ::comphelper::OInterfaceContainerHelper4<css::util::XCloseListener> m_aCloseListeners; + ::comphelper::OInterfaceContainerHelper4<css::util::XModifyListener> m_aModifyListeners; + ::comphelper::OInterfaceContainerHelper4<css::document::XStorageChangeListener> m_aStorageChangeListeners; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners; + ::comphelper::OInterfaceContainerHelper4<css::view::XSelectionChangeListener> m_aSelectionChangeListeners; protected: - SAL_DLLPRIVATE virtual bool impl_canStartApiCall(); - SAL_DLLPRIVATE virtual void impl_apiCallCountReachedNull(){} + SAL_DLLPRIVATE virtual bool impl_canStartApiCall(); + SAL_DLLPRIVATE virtual void impl_apiCallCountReachedNull(std::unique_lock<std::mutex>& /*rGuard*/){} SAL_DLLPRIVATE void impl_registerApiCall(bool bLongLastingCall); - SAL_DLLPRIVATE void impl_unregisterApiCall(bool bLongLastingCall); + SAL_DLLPRIVATE void impl_unregisterApiCall(std::unique_lock<std::mutex>& rGuard, bool bLongLastingCall); -protected: css::lang::XComponent* m_pComponent; - ::osl::Condition m_aNoAccessCountCondition; sal_Int32 m_nAccessCount; - bool volatile m_bDisposed; bool volatile m_bInDispose; - ::osl::Condition m_aNoLongLastingCallCountCondition; sal_Int32 m_nLongLastingCallCount; }; @@ -97,10 +99,10 @@ public: private: virtual bool impl_canStartApiCall() override; - virtual void impl_apiCallCountReachedNull() override; + virtual void impl_apiCallCountReachedNull(std::unique_lock<std::mutex>& rGuard) override; void impl_setOwnership( bool bDeliverOwnership, bool bMyVeto ); - void impl_doClose(); + void impl_doClose(std::unique_lock<std::mutex>& rGuard); }; /* @@ -179,10 +181,10 @@ public: } bool startApiCall(bool bLongLastingCall=false); ~LifeTimeGuard(); - void clear() { m_guard.clear(); } + void clear() { m_guard.unlock(); } private: - osl::ClearableMutexGuard m_guard; + std::unique_lock<std::mutex> m_guard; LifeTimeManager& m_rManager; bool m_bCallRegistered; bool m_bLongLastingCallRegistered; @@ -192,24 +194,6 @@ private: LifeTimeGuard& operator= ( const LifeTimeGuard& ) = delete; }; -template<class T> -class NegativeGuard final -{ - T * m_pT; -public: - - NegativeGuard(T & t) : m_pT(&t) - { - m_pT->release(); - } - - ~NegativeGuard() - { - m_pT->acquire(); - } -}; - }//end namespace apphelper -#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |