diff options
author | Noel Grandin <noel@peralex.com> | 2015-06-29 09:15:16 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-06-29 09:16:18 +0200 |
commit | 371200675c2fb2fef0ac8362ebd7bf4203835440 (patch) | |
tree | f694a17d0837d052be53ae104b3390b189bb846d /package/inc/mutexholder.hxx | |
parent | efc66942f29c0127691d30a9d4f31b684443b672 (diff) |
drop yet another reimplementation of rtl::Reference (SotMutexHolderRef)
Change-Id: I57f9dff931242405420bd45fae7ec5f13718707f
Diffstat (limited to 'package/inc/mutexholder.hxx')
-rw-r--r-- | package/inc/mutexholder.hxx | 86 |
1 files changed, 7 insertions, 79 deletions
diff --git a/package/inc/mutexholder.hxx b/package/inc/mutexholder.hxx index 4b2e47f208dc..dac105f0157c 100644 --- a/package/inc/mutexholder.hxx +++ b/package/inc/mutexholder.hxx @@ -21,102 +21,30 @@ #define INCLUDED_PACKAGE_INC_MUTEXHOLDER_HXX #include <osl/mutex.hxx> +#include <rtl/ref.hxx> class SotMutexHolder { +friend class rtl::Reference<SotMutexHolder>; + ::osl::Mutex m_aMutex; sal_Int32 m_nRefCount; - public: - SotMutexHolder() : m_nRefCount( 0 ) {} - - void AddRef() + void acquire() { m_nRefCount++; } - void ReleaseRef() + void release() { if ( !--m_nRefCount ) delete this; } - ::osl::Mutex& GetMutex() { return m_aMutex; } -}; - -class SotMutexHolderRef -{ - SotMutexHolder* m_pHolder; - public: - SotMutexHolderRef() - : m_pHolder( NULL ) - {} - - SotMutexHolderRef( SotMutexHolder* pHolder ) - : m_pHolder( pHolder ) - { - if ( m_pHolder ) - m_pHolder->AddRef(); - } - - SotMutexHolderRef( const SotMutexHolderRef& rRef ) - : m_pHolder( rRef.m_pHolder ) - { - if ( m_pHolder ) - m_pHolder->AddRef(); - } - - ~SotMutexHolderRef() - { - if ( m_pHolder ) - m_pHolder->ReleaseRef(); - } - - SotMutexHolderRef& operator =( const SotMutexHolderRef& rRef ) - { - if ( m_pHolder ) - m_pHolder->ReleaseRef(); - - m_pHolder = rRef.m_pHolder; - - if ( m_pHolder ) - m_pHolder->AddRef(); - - return *this; - } - - SotMutexHolderRef& operator =( SotMutexHolder* pHolder ) - { - if ( m_pHolder ) - m_pHolder->ReleaseRef(); - - m_pHolder = pHolder; - - if ( m_pHolder ) - m_pHolder->AddRef(); - return *this; - } - - SotMutexHolder* operator ->() const - { - return m_pHolder; - } - - SotMutexHolder& operator *() const - { - return *m_pHolder; - } - - operator SotMutexHolder*() const - { - return m_pHolder; - } + SotMutexHolder() : m_nRefCount( 0 ) {} - bool Is() const - { - return m_pHolder != NULL; - } + ::osl::Mutex& GetMutex() { return m_aMutex; } }; #endif |