Kaydet (Commit) 9e7447d3 authored tarafından Gurkaran's avatar Gurkaran Kaydeden (comit) Noel Grandin

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

It is to improve the readability of calls to osl::Thread::wait.

Change-Id: I025d89abf8e84ca73ba08f001be3f45b86c89957
Signed-off-by: 's avatarGurkaran <gurkran@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/23416Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 7f36f4ce
......@@ -19,6 +19,7 @@
#include <config_folders.h>
#include <config_features.h>
#include <chrono>
#include "dp_misc.h"
#include "dp_version.hxx"
......@@ -458,8 +459,7 @@ Reference<XInterface> resolveUnoURL(
catch (const connection::NoConnectException &) {
if (i < 20)
{
TimeValue tv = { 0 /* secs */, 500000000 /* nanosecs */ };
::osl::Thread::wait( tv );
::osl::Thread::wait( std::chrono::milliseconds(500) );
}
else throw;
}
......
......@@ -28,14 +28,11 @@
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
#include <osl/thread.hxx>
#include <chrono>
static void impl_sleep( sal_uInt32 nSec )
{
TimeValue aTime;
aTime.Seconds = nSec;
aTime.Nanosec = 0;
osl::Thread::wait( aTime );
osl::Thread::wait( std::chrono::seconds(nSec) );
}
HelpCompiler::HelpCompiler(StreamTable &in_streamTable, const fs::path &in_inputFile,
const fs::path &in_src, const fs::path &in_zipdir, const fs::path &in_resCompactStylesheet,
......
......@@ -24,6 +24,7 @@
#include "osl/conditn.hxx"
#include "osl/thread.hxx"
#include "osl/time.h"
#include <chrono>
namespace {
......@@ -62,8 +63,7 @@ public:
// terminates:
global.set();
// Give the spawned threads enough time to terminate:
TimeValue const twentySeconds = { 20, 0 };
osl::Thread::wait(twentySeconds);
osl::Thread::wait(std::chrono::seconds(20));
}
CPPUNIT_TEST_SUITE(Test);
......
......@@ -31,6 +31,7 @@
#include <controller/SlideSorterController.hxx>
#include <controller/SlsClipboard.hxx>
#include <controller/SlsPageSelector.hxx>
#include <chrono>
using namespace ::com::sun::star;
......@@ -85,8 +86,7 @@ sd::DrawDocShellRef SdMiscTest::Load(const OUString& rURL, sal_Int32 nFormat)
while (Scheduler::ProcessTaskScheduling(true));
if ((pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase())) != nullptr)
break;
TimeValue aSleep(0, 100 * 1000000); // 100 msec
osl::Thread::wait(aSleep);
osl::Thread::wait(std::chrono::milliseconds(100));
}
CPPUNIT_ASSERT(pSSVS);
......@@ -126,8 +126,7 @@ void SdMiscTest::testTdf96708()
xSSController.GetClipboard().DoCopy();
// Now wait for timers to trigger creation of auto-layout
TimeValue aSleep(0, 100 * 1000000); // 100 msec
osl::Thread::wait(aSleep);
osl::Thread::wait(std::chrono::milliseconds(100));
Scheduler::ProcessTaskScheduling(true);
xSSController.GetClipboard().DoPaste();
......
......@@ -14,6 +14,7 @@
#include <osl/thread.hxx>
#include <salhelper/thread.hxx>
#include <chrono>
#include <vcl/timer.hxx>
#include <vcl/idle.hxx>
......@@ -39,10 +40,7 @@ public:
}
virtual void SAL_CALL run() override
{
TimeValue aWait;
aWait.Seconds = mnSeconds;
aWait.Nanosec = 1000000; // +1ms
osl::Thread::wait( aWait );
osl::Thread::wait( std::chrono::seconds(mnSeconds) );
fprintf(stderr, "ERROR: WatchDog timer thread expired, failing the test!\n");
fflush(stderr);
CPPUNIT_ASSERT_MESSAGE("watchdog triggered", false);
......@@ -90,10 +88,7 @@ public:
void TimerTest::testWatchdog()
{
// out-wait the watchdog.
TimeValue aWait;
aWait.Seconds = 12;
aWait.Nanosec = 0;
osl::Thread::wait( aWait );
osl::Thread::wait( std::chrono::seconds(12) );
}
#endif
......@@ -339,10 +334,7 @@ public:
}
virtual void Invoke() override
{
TimeValue aWait;
aWait.Seconds = 1;
aWait.Nanosec = 0;
osl::Thread::wait( aWait );
osl::Thread::wait( std::chrono::seconds(1) );
mbSlow = true;
}
};
......
......@@ -8,6 +8,7 @@
*/
#include <config_opengl.h>
#include <chrono>
#include <vcl/opengl/OpenGLContext.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
......@@ -1543,8 +1544,7 @@ void OpenGLContext::swapBuffers()
if (bSleep)
{
// half a second.
TimeValue aSleep( 0, 500*1000*1000 );
osl::Thread::wait( aSleep );
osl::Thread::wait( std::chrono::milliseconds(500) );
}
}
......
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