[rkward-cvs] SF.net SVN: rkward:[3694] trunk/rkward/rkward/rbackend/rkrbackend.cpp

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Jun 20 18:32:25 UTC 2011


Revision: 3694
          http://rkward.svn.sourceforge.net/rkward/?rev=3694&view=rev
Author:   tfry
Date:     2011-06-20 18:32:25 +0000 (Mon, 20 Jun 2011)

Log Message:
-----------
Slow down processing, if a request is not answered within a few seconds.

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rkrbackend.cpp

Modified: trunk/rkward/rkward/rbackend/rkrbackend.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkrbackend.cpp	2011-06-17 11:50:49 UTC (rev 3693)
+++ trunk/rkward/rkward/rbackend/rkrbackend.cpp	2011-06-20 18:32:25 UTC (rev 3694)
@@ -1304,11 +1304,16 @@
 		return 0;
 	}
 
+	int i = 0;
 	while (!request->done) {
 		if (killed) return 0;
 		// NOTE: processX11Events() may, conceivably, lead to new requests, which may also wait for sub-commands!
 		processX11Events ();
-		if (!request->done) RKRBackendProtocolBackend::msleep (10);
+		// NOTE: sleeping and waking up again can be surprisingly CPU-intensive (yes: more than the event processing, above. I have profiled it).
+		// However, we really don't want to introduce too much delay, either.
+		// Thus, the logic is this: If there was no reply within 2 seconds, then probably we're waiting for a user event, and can afford some more
+		// latency (not too much, though, as we still need to process events).
+		if (!request->done) RKRBackendProtocolBackend::msleep (++i < 200 ? 10 : 50);
 	}
 
 	RCommandProxy* command = request->takeCommand ();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list