From 783913e79c0e5a77461a1ac99b0a3fba8498fe0b Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 14 Dec 2009 11:10:30 +0100 Subject: [PATCH] RemotePlugin: sleep in waitForMessage() when actively waiting for data RemotePlugin::waitForMessage() can operate in polling mode which is used when loading a remote plugin so the master application does not block until the remote plugin has been loaded. This is achieved by calling QCoreApplication::processEvents(). However if there're no events to process, the polling loop will just eat up CPU time which is especially bad when on a single core system. This has been fixed by inserting short sleeps. --- include/RemotePlugin.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/RemotePlugin.h b/include/RemotePlugin.h index 1fef44622..9b8710d17 100644 --- a/include/RemotePlugin.h +++ b/include/RemotePlugin.h @@ -36,6 +36,7 @@ #include #ifdef LMMS_BUILD_WIN32 +#include #define USE_QT_SEMAPHORES #define USE_QT_SHMEM #endif @@ -966,6 +967,11 @@ RemotePluginBase::message RemotePluginBase::waitForMessage( { QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents, 50 ); +#ifdef LMMS_BUILD_WIN32 + Sleep( 5 ); +#else + usleep( 5 * 1000 ); +#endif continue; } #endif