[Libreoffice-commits] core.git: comphelper/source desktop/source filter/qa filter/source libreofficekit/source package/source vcl/headless vcl/inc vcl/osx vcl/qt5
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 20 08:20:35 UTC 2019
comphelper/source/misc/threadpool.cxx | 8 ++++----
desktop/source/lib/init.cxx | 2 +-
filter/qa/cppunit/xslt-test.cxx | 2 +-
filter/source/xsltfilter/LibXSLTTransformer.cxx | 6 +++---
libreofficekit/source/gtk/lokdocview.cxx | 8 ++++----
package/source/zipapi/XBufferedThreadedStream.cxx | 2 +-
vcl/headless/svpinst.cxx | 8 ++++++--
vcl/inc/osx/runinmain.hxx | 6 +++---
vcl/osx/salinst.cxx | 4 ++--
vcl/qt5/Qt5Instance.cxx | 6 +++---
10 files changed, 28 insertions(+), 24 deletions(-)
New commits:
commit 6ad13e0e5d1caa8e1ffcf7092e1c04011b5df055
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Jun 20 09:03:25 2019 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Jun 20 10:19:33 2019 +0200
Demote from std::unique_lock to std::scoped_lock where applicable
Change-Id: I53a019f05978bab62ad0da3d0eb08f37f8ec1e18
Reviewed-on: https://gerrit.libreoffice.org/74414
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx
index e1b256736cfe..edef87a844f2 100644
--- a/comphelper/source/misc/threadpool.cxx
+++ b/comphelper/source/misc/threadpool.cxx
@@ -189,7 +189,7 @@ void ThreadPool::shutdownLocked(std::unique_lock<std::mutex>& aGuard)
void ThreadPool::pushTask( std::unique_ptr<ThreadTask> pTask )
{
- std::unique_lock< std::mutex > aGuard( maMutex );
+ std::scoped_lock< std::mutex > aGuard( maMutex );
mbTerminate = false;
@@ -296,14 +296,14 @@ ThreadTaskTag::ThreadTaskTag() : mnTasksWorking(0)
void ThreadTaskTag::onTaskPushed()
{
- std::unique_lock< std::mutex > aGuard( maMutex );
+ std::scoped_lock< std::mutex > aGuard( maMutex );
mnTasksWorking++;
assert( mnTasksWorking < 65536 ); // sanity checking
}
void ThreadTaskTag::onTaskWorkerDone()
{
- std::unique_lock< std::mutex > aGuard( maMutex );
+ std::scoped_lock< std::mutex > aGuard( maMutex );
mnTasksWorking--;
assert(mnTasksWorking >= 0);
if (mnTasksWorking == 0)
@@ -312,7 +312,7 @@ void ThreadTaskTag::onTaskWorkerDone()
bool ThreadTaskTag::isDone()
{
- std::unique_lock< std::mutex > aGuard( maMutex );
+ std::scoped_lock< std::mutex > aGuard( maMutex );
return mnTasksWorking == 0;
}
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 23205bb7afa7..0d7d1327a40f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1434,7 +1434,7 @@ void CallbackFlushHandler::Invoke()
if (m_pCallback && !m_bEventLatch)
{
- std::unique_lock<std::mutex> lock(m_mutex);
+ std::scoped_lock<std::mutex> lock(m_mutex);
SAL_INFO("lok", "Flushing " << m_queue.size() << " elements.");
for (const auto& rCallbackData : m_queue)
diff --git a/filter/qa/cppunit/xslt-test.cxx b/filter/qa/cppunit/xslt-test.cxx
index aab6e3287bde..061f25c43133 100644
--- a/filter/qa/cppunit/xslt-test.cxx
+++ b/filter/qa/cppunit/xslt-test.cxx
@@ -82,7 +82,7 @@ private:
}
void notifyDone() {
- std::unique_lock<std::mutex> g(m_mutex);
+ std::scoped_lock<std::mutex> g(m_mutex);
m_bDone = true;
m_cond.notify_all();
}
diff --git a/filter/source/xsltfilter/LibXSLTTransformer.cxx b/filter/source/xsltfilter/LibXSLTTransformer.cxx
index e4e31cdb351f..c2b9e9dd65fb 100644
--- a/filter/source/xsltfilter/LibXSLTTransformer.cxx
+++ b/filter/source/xsltfilter/LibXSLTTransformer.cxx
@@ -298,7 +298,7 @@ namespace XSLT
xsltTransformContextPtr tcontext = xsltNewTransformContext(
styleSheet, doc);
{
- std::unique_lock<std::mutex> g(m_mutex);
+ std::scoped_lock<std::mutex> g(m_mutex);
m_tcontext = tcontext;
}
oh->registercontext(m_tcontext);
@@ -334,7 +334,7 @@ namespace XSLT
xsltFreeStylesheet(styleSheet);
xsltTransformContextPtr tcontext = nullptr;
{
- std::unique_lock<std::mutex> g(m_mutex);
+ std::scoped_lock<std::mutex> g(m_mutex);
std::swap(m_tcontext, tcontext);
}
xsltFreeTransformContext(tcontext);
@@ -360,7 +360,7 @@ namespace XSLT
void Reader::forceStateStopped()
{
- std::unique_lock<std::mutex> g(m_mutex);
+ std::scoped_lock<std::mutex> g(m_mutex);
if (!m_tcontext)
return;
//tdf#100057 If we force a cancel, libxslt will of course just keep on going unless something
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 3f43a1487502..788377cdfc2e 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -684,7 +684,7 @@ postKeyEventInThread(gpointer data)
LOKDocViewPrivate& priv = getPrivate(pDocView);
LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
- std::unique_lock<std::mutex> aGuard(g_aLOKMutex);
+ std::scoped_lock<std::mutex> aGuard(g_aLOKMutex);
std::stringstream ss;
ss << "lok::Document::setView(" << priv->m_nViewId << ")";
g_info("%s", ss.str().c_str());
@@ -3608,7 +3608,7 @@ lok_doc_view_get_parts (LOKDocView* pDocView)
if (!priv->m_pDocument)
return -1;
- std::unique_lock<std::mutex> aGuard(g_aLOKMutex);
+ std::scoped_lock<std::mutex> aGuard(g_aLOKMutex);
std::stringstream ss;
ss << "lok::Document::setView(" << priv->m_nViewId << ")";
g_info("%s", ss.str().c_str());
@@ -3623,7 +3623,7 @@ lok_doc_view_get_part (LOKDocView* pDocView)
if (!priv->m_pDocument)
return -1;
- std::unique_lock<std::mutex> aGuard(g_aLOKMutex);
+ std::scoped_lock<std::mutex> aGuard(g_aLOKMutex);
std::stringstream ss;
ss << "lok::Document::setView(" << priv->m_nViewId << ")";
g_info("%s", ss.str().c_str());
@@ -3668,7 +3668,7 @@ lok_doc_view_get_part_name (LOKDocView* pDocView, int nPart)
if (!priv->m_pDocument)
return nullptr;
- std::unique_lock<std::mutex> aGuard(g_aLOKMutex);
+ std::scoped_lock<std::mutex> aGuard(g_aLOKMutex);
std::stringstream ss;
ss << "lok::Document::setView(" << priv->m_nViewId << ")";
g_info("%s", ss.str().c_str());
diff --git a/package/source/zipapi/XBufferedThreadedStream.cxx b/package/source/zipapi/XBufferedThreadedStream.cxx
index 6bc7da7fa173..aeeb6956304b 100644
--- a/package/source/zipapi/XBufferedThreadedStream.cxx
+++ b/package/source/zipapi/XBufferedThreadedStream.cxx
@@ -125,7 +125,7 @@ const Buffer& XBufferedThreadedStream::getNextBlock()
void XBufferedThreadedStream::setTerminateThread()
{
- std::unique_lock<std::mutex> aGuard( maBufferProtector );
+ std::scoped_lock<std::mutex> aGuard( maBufferProtector );
mbTerminateThread = true;
maBufferProduceResume.notify_one();
maBufferConsumeResume.notify_one();
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 02e332b92fbf..335f70e4bba7 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <mutex>
+
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
@@ -173,7 +177,7 @@ void SvpSalInstance::Wakeup(SvpRequest const request)
pSVData->mpWakeCallback(pSVData->mpPollClosure);
SvpSalYieldMutex *const pMutex(static_cast<SvpSalYieldMutex*>(GetYieldMutex()));
- std::unique_lock<std::mutex> g(pMutex->m_WakeUpMainMutex);
+ std::scoped_lock<std::mutex> g(pMutex->m_WakeUpMainMutex);
if (request != SvpRequest::NONE)
pMutex->m_Request = request;
pMutex->m_wakeUpMain = true;
@@ -373,7 +377,7 @@ sal_uInt32 SvpSalYieldMutex::doRelease(bool const bUnlockAll)
}
else
{
- std::unique_lock<std::mutex> g(m_WakeUpMainMutex);
+ std::scoped_lock<std::mutex> g(m_WakeUpMainMutex);
m_wakeUpMain = true;
m_WakeUpMainCond.notify_one();
}
diff --git a/vcl/inc/osx/runinmain.hxx b/vcl/inc/osx/runinmain.hxx
index 287479981aa3..e68bc4d35010 100644
--- a/vcl/inc/osx/runinmain.hxx
+++ b/vcl/inc/osx/runinmain.hxx
@@ -72,7 +72,7 @@ union RuninmainResult
DBG_TESTSOLARMUTEX(); \
SalYieldMutex *aMutex = static_cast<SalYieldMutex*>(instance->GetYieldMutex()); \
{ \
- std::unique_lock<std::mutex> g(aMutex->m_runInMainMutex); \
+ std::scoped_lock<std::mutex> g(aMutex->m_runInMainMutex); \
assert( !aMutex->m_aCodeBlock ); \
aMutex->m_aCodeBlock = Block_copy(^{ \
command; \
@@ -98,7 +98,7 @@ union RuninmainResult
DBG_TESTSOLARMUTEX(); \
SalYieldMutex *aMutex = static_cast<SalYieldMutex*>(instance->GetYieldMutex()); \
{ \
- std::unique_lock<std::mutex> g(aMutex->m_runInMainMutex); \
+ std::scoped_lock<std::mutex> g(aMutex->m_runInMainMutex); \
assert( !aMutex->m_aCodeBlock ); \
aMutex->m_aCodeBlock = Block_copy(^{ \
aMutex->m_aResult.pointer = static_cast<void*>( command ); \
@@ -124,7 +124,7 @@ union RuninmainResult
DBG_TESTSOLARMUTEX(); \
SalYieldMutex *aMutex = static_cast<SalYieldMutex*>(instance->GetYieldMutex()); \
{ \
- std::unique_lock<std::mutex> g(aMutex->m_runInMainMutex); \
+ std::scoped_lock<std::mutex> g(aMutex->m_runInMainMutex); \
assert( !aMutex->m_aCodeBlock ); \
aMutex->m_aCodeBlock = Block_copy(^{ \
aMutex->m_aResult.member = command; \
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index b31f870d9e12..6ed28b7a1d5a 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -232,7 +232,7 @@ void SalYieldMutex::doAcquire( sal_uInt32 nLockCount )
block();
pInst->mbNoYieldLock = false;
Block_release( block );
- std::unique_lock<std::mutex> g(m_runInMainMutex);
+ std::scoped_lock<std::mutex> g(m_runInMainMutex);
assert(!m_resultReady);
m_resultReady = true;
m_aResultCondition.notify_all();
@@ -255,7 +255,7 @@ sal_uInt32 SalYieldMutex::doRelease( const bool bUnlockAll )
return 1;
sal_uInt32 nCount;
{
- std::unique_lock<std::mutex> g(m_runInMainMutex);
+ std::scoped_lock<std::mutex> g(m_runInMainMutex);
// read m_nCount before doRelease
bool const isReleased(bUnlockAll || m_nCount == 1);
nCount = comphelper::SolarMutex::doRelease( bUnlockAll );
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index d657ab729801..6c872b84cb0a 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -132,7 +132,7 @@ void Qt5YieldMutex::doAcquire(sal_uInt32 nLockCount)
m_bNoYieldLock = true; // execute closure with borrowed SolarMutex
func();
m_bNoYieldLock = false;
- std::unique_lock<std::mutex> g(m_RunInMainMutex);
+ std::scoped_lock<std::mutex> g(m_RunInMainMutex);
assert(!m_isResultReady);
m_isResultReady = true;
m_ResultCondition.notify_all(); // unblock other thread
@@ -150,7 +150,7 @@ sal_uInt32 Qt5YieldMutex::doRelease(bool const bUnlockAll)
return 1; // dummy value
}
- std::unique_lock<std::mutex> g(m_RunInMainMutex);
+ std::scoped_lock<std::mutex> g(m_RunInMainMutex);
// read m_nCount before doRelease (it's guarded by m_aMutex)
bool const isReleased(bUnlockAll || m_nCount == 1);
sal_uInt32 nCount = SalYieldMutex::doRelease(bUnlockAll);
@@ -177,7 +177,7 @@ void Qt5Instance::RunInMainThread(std::function<void()> func)
Qt5YieldMutex* const pMutex(static_cast<Qt5YieldMutex*>(GetYieldMutex()));
{
- std::unique_lock<std::mutex> g(pMutex->m_RunInMainMutex);
+ std::scoped_lock<std::mutex> g(pMutex->m_RunInMainMutex);
assert(!pMutex->m_Closure);
pMutex->m_Closure = func;
// unblock main thread in case it is blocked on condition
More information about the Libreoffice-commits
mailing list