diff options
author | Gurkaran <gurkran@gmail.com> | 2016-03-22 03:25:02 +0530 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-03-22 06:54:08 +0000 |
commit | 9e7447d39e356857ef5786b513e99cee79385247 (patch) | |
tree | 12ab8cf850a2af5053959def004db5c463237008 | |
parent | Fix wrong pattern definitions in khmer dictionary breaker (diff) | |
download | core-9e7447d39e356857ef5786b513e99cee79385247.tar.gz core-9e7447d39e356857ef5786b513e99cee79385247.zip |
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: Gurkaran <gurkran@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/23416
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r-- | desktop/source/deployment/misc/dp_misc.cxx | 4 | ||||
-rw-r--r-- | helpcompiler/source/HelpCompiler.cxx | 7 | ||||
-rw-r--r-- | sal/qa/osl/thread/test_thread.cxx | 4 | ||||
-rw-r--r-- | sd/qa/unit/misc-tests.cxx | 7 | ||||
-rw-r--r-- | vcl/qa/cppunit/timer.cxx | 16 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLContext.cxx | 4 |
6 files changed, 15 insertions, 27 deletions
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 9930d6a70c84..24f23a585e30 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -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; } diff --git a/helpcompiler/source/HelpCompiler.cxx b/helpcompiler/source/HelpCompiler.cxx index 2a127fe2bb44..c25b69bc1933 100644 --- a/helpcompiler/source/HelpCompiler.cxx +++ b/helpcompiler/source/HelpCompiler.cxx @@ -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, diff --git a/sal/qa/osl/thread/test_thread.cxx b/sal/qa/osl/thread/test_thread.cxx index 5030af1df57f..12ddafc6d792 100644 --- a/sal/qa/osl/thread/test_thread.cxx +++ b/sal/qa/osl/thread/test_thread.cxx @@ -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); diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 0d34f507dcaf..ab5b45e5b893 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -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(); diff --git a/vcl/qa/cppunit/timer.cxx b/vcl/qa/cppunit/timer.cxx index 0d3afa1ace8d..07fdc92ffbac 100644 --- a/vcl/qa/cppunit/timer.cxx +++ b/vcl/qa/cppunit/timer.cxx @@ -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; } }; diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index 7f920c0370b7..3da890ae4e2e 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -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) ); } } |