cppuhelper/source/bootstrap.cxx | 3 ++- desktop/source/app/officeipcthread.cxx | 16 ++++------------ desktop/source/deployment/misc/dp_misc.cxx | 3 ++- package/source/zipapi/ZipOutputStream.cxx | 4 +++- slideshow/source/engine/slideshowimpl.cxx | 3 ++- stoc/source/javaloader/javaloader.cxx | 5 +++-- sw/source/core/docnode/finalthreadmanager.cxx | 5 +++-- testtools/source/bridgetest/cppobj.cxx | 3 ++- toolkit/source/awt/vclxtoolkit.cxx | 3 ++- ucb/source/ucp/webdav-curl/SerfLockStore.cxx | 7 +++---- vcl/source/opengl/OpenGLContext.cxx | 3 ++- vcl/unx/generic/dtrans/X11_selection.cxx | 5 +++-- vcl/workben/vcldemo.cxx | 3 ++- 13 files changed, 33 insertions(+), 30 deletions(-)
New commits: commit 555f4333182abd0ca4aa06b354763f6dfbc3eb20 Author: Arnaud VERSINI <arnaud.vers...@libreoffice.org> AuthorDate: Sun Nov 6 17:04:20 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Mon Jan 9 08:37:35 2023 +0000 use std::this_thread::sleep_for instead of osl equivalent Change-Id: I5b4edc5417e5bb5e082688df616e1d5735717d92 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142357 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx index f468518ba456..bd975460f06c 100644 --- a/cppuhelper/source/bootstrap.cxx +++ b/cppuhelper/source/bootstrap.cxx @@ -21,6 +21,7 @@ #include <chrono> #include <cstring> +#include <thread> #include <rtl/bootstrap.hxx> #include <rtl/random.h> @@ -215,7 +216,7 @@ Reference< XComponentContext > SAL_CALL bootstrap() catch ( connection::NoConnectException & ) { // wait 500 ms, then try to connect again - ::osl::Thread::wait( std::chrono::milliseconds(500) ); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); } } } diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index 45b8906c3b42..74f838939bfa 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -48,6 +48,7 @@ #include <cassert> #include <cstdlib> #include <memory> +#include <thread> #if ENABLE_DBUS #include <dbus/dbus.h> @@ -792,10 +793,7 @@ RequestHandler::Status PipeIpcThread::enable(rtl::Reference<IpcThread> * thread) else { // Pipe connection failed (other office exited or crashed) - TimeValue tval; - tval.Seconds = 0; - tval.Nanosec = 500000000; - salhelper::Thread::wait( tval ); + std::this_thread::sleep_for( std::chrono::milliseconds(500) ); } } else @@ -805,10 +803,7 @@ RequestHandler::Status PipeIpcThread::enable(rtl::Reference<IpcThread> * thread) return RequestHandler::IPC_STATUS_PIPE_ERROR; // Wait for second office to be ready - TimeValue aTimeValue; - aTimeValue.Seconds = 0; - aTimeValue.Nanosec = 10000000; // 10ms - salhelper::Thread::wait( aTimeValue ); + std::this_thread::sleep_for( std::chrono::milliseconds(10) ); } } while ( nPipeMode == PIPEMODE_DONTKNOW ); @@ -1206,10 +1201,7 @@ void PipeIpcThread::execute() } SAL_WARN( "desktop.app", "Error on accept: " << static_cast<int>(nError)); - TimeValue tval; - tval.Seconds = 1; - tval.Nanosec = 0; - salhelper::Thread::wait( tval ); + std::this_thread::sleep_for( std::chrono::seconds(1) ); } } while( schedule() ); } diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 2983de24b959..bbe3a085fc68 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/task/OfficeRestartManager.hpp> #include <memory> #include <string_view> +#include <thread> #include <comphelper/lok.hxx> #include <comphelper/processfactory.hxx> #include <salhelper/linkhelper.hxx> @@ -447,7 +448,7 @@ Reference<XInterface> resolveUnoURL( catch (const connection::NoConnectException &) { if (i < 40) { - ::osl::Thread::wait( std::chrono::milliseconds(500) ); + std::this_thread::sleep_for( std::chrono::milliseconds(500) ); } else throw; } diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index 9b582c4691e8..df21f1ffeb13 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -32,6 +32,8 @@ #include <ZipOutputEntry.hxx> #include <ZipPackageStream.hxx> +#include <thread> + using namespace com::sun::star; using namespace com::sun::star::io; using namespace com::sun::star::uno; @@ -151,7 +153,7 @@ void ZipOutputStream::reduceScheduledThreadTasksToGivenNumberOrLess(std::size_t if(m_aEntries.size() > nThreadTasks) { - osl::Thread::wait(std::chrono::microseconds(100)); + std::this_thread::sleep_for(std::chrono::microseconds(100)); } } } diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx index 264a4dee8217..923ea26d0bc0 100644 --- a/slideshow/source/engine/slideshowimpl.cxx +++ b/slideshow/source/engine/slideshowimpl.cxx @@ -82,6 +82,7 @@ #include "pointersymbol.hxx" #include <map> +#include <thread> #include <utility> #include <vector> #include <algorithm> @@ -2416,7 +2417,7 @@ void FrameSynchronization::Synchronize() // Try to sleep most of it. int remainingMilliseconds = remainingTime * 1000; if(remainingMilliseconds > 2) - osl::Thread::wait(std::chrono::milliseconds(remainingMilliseconds - 2)); + std::this_thread::sleep_for(std::chrono::milliseconds(remainingMilliseconds - 2)); } } diff --git a/stoc/source/javaloader/javaloader.cxx b/stoc/source/javaloader/javaloader.cxx index f463e8791985..c8ad708ec676 100644 --- a/stoc/source/javaloader/javaloader.cxx +++ b/stoc/source/javaloader/javaloader.cxx @@ -46,7 +46,6 @@ #include <rtl/random.h> #include <rtl/ustrbuf.hxx> #include <osl/security.hxx> -#include <osl/thread.hxx> #include <cppuhelper/factory.hxx> @@ -67,6 +66,8 @@ // this one is header-only #include <comphelper/sequence.hxx> + +#include <thread> #include <utility> namespace com::sun::star::registry { class XRegistryKey; } @@ -210,7 +211,7 @@ Reference<XComponentContext> raise_uno_process( } catch (const css::connection::NoConnectException &) { if (i < 40) { - ::osl::Thread::wait( std::chrono::milliseconds(500) ); + std::this_thread::sleep_for( std::chrono::milliseconds(500) ); } else throw; } diff --git a/sw/source/core/docnode/finalthreadmanager.cxx b/sw/source/core/docnode/finalthreadmanager.cxx index 9d293b05492f..73a0feccfaff 100644 --- a/sw/source/core/docnode/finalthreadmanager.cxx +++ b/sw/source/core/docnode/finalthreadmanager.cxx @@ -29,6 +29,7 @@ #include <rtl/ustring.hxx> #include <cppuhelper/supportsservice.hxx> #include <mutex> +#include <thread> #include <utility> /** thread to cancel a give list of cancellable jobs @@ -133,7 +134,7 @@ void SAL_CALL CancelJobsThread::run() mbAllJobsCancelled = true; { - osl::Thread::wait(std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(1)); } } } @@ -347,7 +348,7 @@ void SAL_CALL FinalThreadManager::queryTermination( const css::lang::EventObject if ( mpCancelJobsThread != nullptr && !mpCancelJobsThread->allJobsCancelled() ) { - osl::Thread::wait(std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(1)); } if ( mpCancelJobsThread != nullptr && diff --git a/testtools/source/bridgetest/cppobj.cxx b/testtools/source/bridgetest/cppobj.cxx index 13eb1e6440aa..32742110f341 100644 --- a/testtools/source/bridgetest/cppobj.cxx +++ b/testtools/source/bridgetest/cppobj.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <thread> #include <utility> #include <cppu/unotype.hxx> @@ -512,7 +513,7 @@ namespace { void wait(sal_Int32 microSeconds) { OSL_ASSERT(microSeconds >= 0 && microSeconds <= SAL_MAX_INT32 / 1000); - osl::Thread::wait(std::chrono::microseconds(microSeconds)); + std::this_thread::sleep_for(std::chrono::microseconds(microSeconds)); } } diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 7a3e3e7cfbcb..b361a20e3d3d 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -20,6 +20,7 @@ #include <sal/config.h> #include <string_view> +#include <thread> #ifdef _WIN32 #include <prewin.h> @@ -417,7 +418,7 @@ public: virtual void Invoke() override { SolarMutexGuard aSolarGuard; - osl::Thread::wait(std::chrono::milliseconds(m_nPauseMilliseconds)); + std::this_thread::sleep_for(std::chrono::milliseconds(m_nPauseMilliseconds)); Stop(); delete this; } diff --git a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx index 005e7c5f10dd..6d7b89e9e687 100644 --- a/ucb/source/ucp/webdav-curl/SerfLockStore.cxx +++ b/ucb/source/ucp/webdav-curl/SerfLockStore.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <chrono> #include <rtl/ustring.hxx> #include <sal/log.hxx> #include <osl/time.h> @@ -24,6 +25,7 @@ #include <salhelper/thread.hxx> #include <com/sun/star/ucb/LockScope.hpp> +#include <thread> #include "CurlSession.hxx" #include "SerfLockStore.hxx" @@ -71,10 +73,7 @@ void TickerThread::execute() nCount = nNth; } - TimeValue aTV; - aTV.Seconds = 0; - aTV.Nanosec = 1000000000 / nNth; - salhelper::Thread::wait( aTV ); + std::this_thread::sleep_for( std::chrono::milliseconds(1000/25) ); } SAL_INFO("ucb.ucp.webdav", "TickerThread: stop." ); diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index b703356ee5d4..e68e66564db2 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -9,6 +9,7 @@ #include <chrono> +#include <thread> #include <vcl/opengl/OpenGLContext.hxx> #include <vcl/opengl/OpenGLHelper.hxx> #include <vcl/opengl/OpenGLWrapper.hxx> @@ -458,7 +459,7 @@ void OpenGLContext::BuffersSwapped() if (bSleep) { // half a second. - osl::Thread::wait( std::chrono::milliseconds(500) ); + std::this_thread::sleep_for(std::chrono::milliseconds(500) ); } } diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index 175da5308e08..3547ef2b7226 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -21,6 +21,7 @@ #include <sal/log.hxx> #include <cstdlib> +#include <thread> #include <unx/saldisp.hxx> @@ -946,7 +947,7 @@ bool SelectionManager::getPasteData( Atom selection, Atom type, Sequence< sal_In else { aGuard.clear(); - osl::Thread::wait(std::chrono::milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); aGuard.reset(); } if( bHandle ) @@ -3501,7 +3502,7 @@ void SelectionManager::dragDoDispatch() { // let the thread in the run method do the dispatching // just look occasionally here whether drop timed out or is completed - osl::Thread::wait(std::chrono::milliseconds(200)); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); } #if OSL_DEBUG_LEVEL > 1 SAL_INFO("vcl.unx.dtrans", "end executeDrag dispatching."); diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 05897bce5f6d..f0e41768f8f3 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -10,6 +10,7 @@ #include <sal/config.h> #include <memory> +#include <thread> #include <config_features.h> @@ -1730,7 +1731,7 @@ class DemoWin : public WorkWindow } virtual void execute() override { - wait(std::chrono::seconds(mnDelaySecs)); + std::this_thread::sleep_for(std::chrono::seconds(mnDelaySecs)); SolarMutexGuard aGuard; fprintf (stderr, "render from a different thread\n");