summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-07-08 15:44:13 +0200
committerNoel Grandin <noel@peralex.com>2014-07-10 11:04:10 +0200
commit3a93809df9ace02da20fa5f91e4c72fa3b3f8a82 (patch)
tree70e7e66a31cc6c93782c1fadc770579b14723ae2 /framework
parentDOCX export: allow multiple runs in w:sdt tags (diff)
downloadcore-3a93809df9ace02da20fa5f91e4c72fa3b3f8a82.tar.gz
core-3a93809df9ace02da20fa5f91e4c72fa3b3f8a82.zip
improvements to ShareableMutex
- add some docs - remove unnecessary null checks - improve field name Change-Id: I8299ec0d56ee5d903f05f2790f97f90ca00663cb
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/helper/shareablemutex.hxx10
-rw-r--r--framework/source/fwi/helper/shareablemutex.cxx29
2 files changed, 17 insertions, 22 deletions
diff --git a/framework/inc/helper/shareablemutex.hxx b/framework/inc/helper/shareablemutex.hxx
index 73c62ab11245..1a3b506906da 100644
--- a/framework/inc/helper/shareablemutex.hxx
+++ b/framework/inc/helper/shareablemutex.hxx
@@ -27,6 +27,9 @@
namespace framework
{
+/**
+ * This acts like a rtl::Reference<osl::Mutex>
+ */
class FWI_DLLPUBLIC ShareableMutex
{
public:
@@ -34,12 +37,15 @@ class FWI_DLLPUBLIC ShareableMutex
ShareableMutex( const ShareableMutex& rShareableMutex );
const ShareableMutex& operator=( const ShareableMutex& rShareableMutex );
- ~ShareableMutex();
+ ~ShareableMutex() { m_pMutexRef->release(); }
+ /** acquire the shared mutex */
void acquire();
+ /** release the shared mutex */
void release();
private:
+ /* ShareableMutex::MutexRef will destroy itself when the last ShareableMutex pointing to it is destroyed */
struct MutexRef
{
MutexRef() : m_refCount(0) {}
@@ -58,7 +64,7 @@ class FWI_DLLPUBLIC ShareableMutex
osl::Mutex m_oslMutex;
};
- MutexRef* pMutexRef;
+ MutexRef* m_pMutexRef;
};
class ShareGuard
diff --git a/framework/source/fwi/helper/shareablemutex.cxx b/framework/source/fwi/helper/shareablemutex.cxx
index 5699d8adabaf..4f674c95e756 100644
--- a/framework/source/fwi/helper/shareablemutex.cxx
+++ b/framework/source/fwi/helper/shareablemutex.cxx
@@ -24,43 +24,32 @@ namespace framework
ShareableMutex::ShareableMutex()
{
- pMutexRef = new MutexRef;
- pMutexRef->acquire();
+ m_pMutexRef = new MutexRef;
+ m_pMutexRef->acquire();
}
ShareableMutex::ShareableMutex( const ShareableMutex& rShareableMutex )
{
- pMutexRef = rShareableMutex.pMutexRef;
- if ( pMutexRef )
- pMutexRef->acquire();
+ m_pMutexRef = rShareableMutex.m_pMutexRef;
+ m_pMutexRef->acquire();
}
const ShareableMutex& ShareableMutex::operator=( const ShareableMutex& rShareableMutex )
{
- if ( rShareableMutex.pMutexRef )
- rShareableMutex.pMutexRef->acquire();
- if ( pMutexRef )
- pMutexRef->release();
- pMutexRef = rShareableMutex.pMutexRef;
+ rShareableMutex.m_pMutexRef->acquire();
+ m_pMutexRef->release();
+ m_pMutexRef = rShareableMutex.m_pMutexRef;
return *this;
}
-ShareableMutex::~ShareableMutex()
-{
- if ( pMutexRef )
- pMutexRef->release();
-}
-
void ShareableMutex::acquire()
{
- if ( pMutexRef )
- pMutexRef->m_oslMutex.acquire();
+ m_pMutexRef->m_oslMutex.acquire();
}
void ShareableMutex::release()
{
- if ( pMutexRef )
- pMutexRef->m_oslMutex.release();
+ m_pMutexRef->m_oslMutex.release();
}
}