Kaydet (Commit) 12fc1d53 authored tarafından Fakabbir Amin's avatar Fakabbir Amin Kaydeden (comit) Noel Grandin

tdf#84323: Make osl::Condition::wait more readable

Improved readability of calls to osl::Condition::wait.

Change-Id: I69fb9815561013f1eb9fd4a649e32902e09473c6
Reviewed-on: https://gerrit.libreoffice.org/34399Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst b8d8fb3f
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <chrono>
#include <cstddef> #include <cstddef>
#include <list> #include <list>
#include <set> #include <set>
...@@ -178,8 +179,7 @@ Components::WriteThread::WriteThread( ...@@ -178,8 +179,7 @@ Components::WriteThread::WriteThread(
} }
void Components::WriteThread::execute() { void Components::WriteThread::execute() {
TimeValue t = { 1, 0 }; // 1 sec delay_.wait(std::chrono::seconds(1)); // must not throw; result_error is harmless and ignored
delay_.wait(&t); // must not throw; result_error is harmless and ignored
osl::MutexGuard g(*lock_); // must not throw osl::MutexGuard g(*lock_); // must not throw
try { try {
try { try {
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <sfx2/lokhelper.hxx> #include <sfx2/lokhelper.hxx>
#include <svx/svdpage.hxx> #include <svx/svdpage.hxx>
#include <chrono>
#include <tabvwsh.hxx> #include <tabvwsh.hxx>
#include <docsh.hxx> #include <docsh.hxx>
#include <document.hxx> #include <document.hxx>
...@@ -352,15 +353,13 @@ void ScTiledRenderingTest::testDocumentSize() ...@@ -352,15 +353,13 @@ void ScTiledRenderingTest::testDocumentSize()
// Set cursor column // Set cursor column
pViewShell->SetCursor(100, 0); pViewShell->SetCursor(100, 0);
// 2 seconds // 2 seconds
TimeValue aTime = { 2 , 0 }; osl::Condition::Result aResult = m_aDocSizeCondition.wait(std::chrono::seconds(2));
osl::Condition::Result aResult = m_aDocSizeCondition.wait(aTime);
CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok);
// Set cursor row // Set cursor row
pViewShell->SetCursor(0, 100); pViewShell->SetCursor(0, 100);
// 2 seconds // 2 seconds
aTime = { 2 , 0 }; aResult = m_aDocSizeCondition.wait(std::chrono::seconds(2));
aResult = m_aDocSizeCondition.wait(aTime);
CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok);
comphelper::LibreOfficeKit::setActive(false); comphelper::LibreOfficeKit::setActive(false);
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
#include <sfx2/request.hxx> #include <sfx2/request.hxx>
#include <svx/svxids.hrc> #include <svx/svxids.hrc>
#include <chrono>
using namespace css; using namespace css;
static const char* const DATA_DIRECTORY = "/sd/qa/unit/tiledrendering/data/"; static const char* const DATA_DIRECTORY = "/sd/qa/unit/tiledrendering/data/";
...@@ -668,8 +670,7 @@ void SdTiledRenderingTest::testInsertDeletePage() ...@@ -668,8 +670,7 @@ void SdTiledRenderingTest::testInsertDeletePage()
for (unsigned it = 1; it <= 10; it++) for (unsigned it = 1; it <= 10; it++)
comphelper::dispatchCommand(".uno:InsertPage", aArgs); comphelper::dispatchCommand(".uno:InsertPage", aArgs);
TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max osl::Condition::Result aResult = m_aDocumentSizeCondition.wait(std::chrono::seconds(2));
osl::Condition::Result aResult = m_aDocumentSizeCondition.wait(aTimeValue);
CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok);
// Verify inserted slides // Verify inserted slides
...@@ -686,7 +687,7 @@ void SdTiledRenderingTest::testInsertDeletePage() ...@@ -686,7 +687,7 @@ void SdTiledRenderingTest::testInsertDeletePage()
for (unsigned it = 1; it <= 10; it++) for (unsigned it = 1; it <= 10; it++)
comphelper::dispatchCommand(".uno:DeletePage", aArgs); comphelper::dispatchCommand(".uno:DeletePage", aArgs);
aResult = m_aDocumentSizeCondition.wait(aTimeValue); aResult = m_aDocumentSizeCondition.wait(std::chrono::seconds(2));
CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok);
// Verify deleted slides // Verify deleted slides
...@@ -702,7 +703,7 @@ void SdTiledRenderingTest::testInsertDeletePage() ...@@ -702,7 +703,7 @@ void SdTiledRenderingTest::testInsertDeletePage()
for (unsigned it = 1; it <= 10; it++) for (unsigned it = 1; it <= 10; it++)
comphelper::dispatchCommand(".uno:Undo", aArgs); comphelper::dispatchCommand(".uno:Undo", aArgs);
aResult = m_aDocumentSizeCondition.wait(aTimeValue); aResult = m_aDocumentSizeCondition.wait(std::chrono::seconds(2));
CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok);
// Verify inserted slides // Verify inserted slides
...@@ -718,7 +719,7 @@ void SdTiledRenderingTest::testInsertDeletePage() ...@@ -718,7 +719,7 @@ void SdTiledRenderingTest::testInsertDeletePage()
for (unsigned it = 1; it <= 10; it++) for (unsigned it = 1; it <= 10; it++)
comphelper::dispatchCommand(".uno:Redo", aArgs); comphelper::dispatchCommand(".uno:Redo", aArgs);
aResult = m_aDocumentSizeCondition.wait(aTimeValue); aResult = m_aDocumentSizeCondition.wait(std::chrono::seconds(2));
CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok);
// Verify deleted slides // Verify deleted slides
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment