summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-07-01 11:36:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-07-04 15:42:15 +0200
commit1a6833a00fb7fcf04c71fcaa05dbee1f15a075d4 (patch)
tree0d9dd45c660ed83ca491e979622de31adc9d78ef /comphelper
parentd30810b5a116816fe8a6d3341aa98e43adc56de2 (diff)
tdf#137544 reduce cost of SolarMutex checking
the std::thread::id facilities are cheaper than the sal versions Change-Id: I5ccb7e54f3a1e4d715338faa1e9c0aae9449e46d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136800 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/solarmutex.cxx9
1 files changed, 4 insertions, 5 deletions
diff --git a/comphelper/source/misc/solarmutex.cxx b/comphelper/source/misc/solarmutex.cxx
index 5d1052327154..3e45ae14582d 100644
--- a/comphelper/source/misc/solarmutex.cxx
+++ b/comphelper/source/misc/solarmutex.cxx
@@ -38,7 +38,6 @@ SolarMutex *SolarMutex::get()
SolarMutex::SolarMutex()
: m_nCount( 0 )
- , m_nThreadId( 0 )
, m_aBeforeReleaseHandler( nullptr )
{
assert(!g_pSolarMutex);
@@ -54,7 +53,7 @@ void SolarMutex::doAcquire( const sal_uInt32 nLockCount )
{
for ( sal_uInt32 n = nLockCount; n ; --n )
m_aMutex.acquire();
- m_nThreadId = osl::Thread::getCurrentIdentifier();
+ m_nThreadId = std::this_thread::get_id();
m_nCount += nLockCount;
}
@@ -72,7 +71,7 @@ sal_uInt32 SolarMutex::doRelease( bool bUnlockAll )
{
if ( m_aBeforeReleaseHandler )
m_aBeforeReleaseHandler();
- m_nThreadId = 0;
+ m_nThreadId = std::thread::id();
}
for ( sal_uInt32 n = nCount ; n ; --n )
@@ -83,14 +82,14 @@ sal_uInt32 SolarMutex::doRelease( bool bUnlockAll )
bool SolarMutex::IsCurrentThread() const
{
- return m_nThreadId == osl::Thread::getCurrentIdentifier();
+ return m_nThreadId == std::this_thread::get_id();
}
bool SolarMutex::tryToAcquire()
{
if ( m_aMutex.tryToAcquire() )
{
- m_nThreadId = osl::Thread::getCurrentIdentifier();
+ m_nThreadId = std::this_thread::get_id();
m_nCount++;
return true;
}