[rkward-cvs] SF.net SVN: rkward:[3691] trunk/rkward/rkward/rbackend

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Jun 16 17:22:25 UTC 2011


Revision: 3691
          http://rkward.svn.sourceforge.net/rkward/?rev=3691&view=rev
Author:   tfry
Date:     2011-06-16 17:22:24 +0000 (Thu, 16 Jun 2011)

Log Message:
-----------
QObject timers appear to cause _slightly_ less overhead than QTimers.
This reduces idle CPU load a bit.

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/rbackend/rinterface.h
    trunk/rkward/rkward/rbackend/rkbackendtransmitter.cpp
    trunk/rkward/rkward/rbackend/rkbackendtransmitter.h

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2011-06-14 17:59:53 UTC (rev 3690)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2011-06-16 17:22:24 UTC (rev 3691)
@@ -59,7 +59,6 @@
 #include <kstandarddirs.h>
 
 #include <qdir.h>
-#include <qtimer.h>
 #include <qvalidator.h>
 
 #include <stdlib.h>
@@ -102,9 +101,7 @@
 	RCommand *fake = new RCommand (i18n ("R Startup"), RCommand::App | RCommand::Sync | RCommand::ObjectListUpdate, i18n ("R Startup"), this, STARTUP_PHASE2_COMPLETE);
 	issueCommand (fake);
 
-	flush_timer = new QTimer (this);
-	connect (flush_timer, SIGNAL (timeout ()), this, SLOT (flushOutput ()));
-	flush_timer->start (FLUSH_INTERVAL);
+	startTimer (FLUSH_INTERVAL);	// calls flushOutput (false); see timerEvent ()
 
 	new RKRBackendProtocolFrontend (this);
 	RKRBackendProtocolFrontend::instance ()->setupBackend ();
@@ -119,7 +116,6 @@
 	RK_TRACE (RBACKEND);
 
 	if (num_active_output_record_requests) RK_DO (qDebug ("%d requests for recording output still active on interface shutdown", num_active_output_record_requests), RBACKEND, DL_WARNING);
-	delete flush_timer;
 	delete window_catcher;
 }
 
@@ -347,10 +343,8 @@
 	}
 }
 
-void RInterface::flushOutput () {
+void RInterface::timerEvent (QTimerEvent *) {
 // do not trace. called periodically
-//	RK_TRACE (RBACKEND);
-
 	flushOutput (false);
 }
 

Modified: trunk/rkward/rkward/rbackend/rinterface.h
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.h	2011-06-14 17:59:53 UTC (rev 3690)
+++ trunk/rkward/rkward/rbackend/rinterface.h	2011-06-16 17:22:24 UTC (rev 3691)
@@ -26,7 +26,6 @@
 
 class RCommand;
 class RKWardMainWindow;
-class QTimer;
 class RKRBackend;
 struct RBackendRequest;
 
@@ -76,16 +75,12 @@
 	bool backendIsIdle ();
 	static bool isNaReal (double value) { return na_real == value; };
 	static bool isNaInt (int value) { return na_int == value; };
-private slots:
-/** called periodically to flush output buffer in RThread */
-	void flushOutput ();
 private:
+	void timerEvent (QTimerEvent *);
 /** Calls RThread::flushOutput(), and takes care of adding the output to all applicable commands */
 	void flushOutput (bool forced);
 /** pointer to the RThread */
 	RKRBackend *r_thread;
-/** Timer to trigger flushing output */
-	QTimer *flush_timer;
 /** Used by the testing framework. see R function rk.record.commands(). */
 	QFile command_logfile;
 	enum {

Modified: trunk/rkward/rkward/rbackend/rkbackendtransmitter.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkbackendtransmitter.cpp	2011-06-14 17:59:53 UTC (rev 3690)
+++ trunk/rkward/rkward/rbackend/rkbackendtransmitter.cpp	2011-06-16 17:22:24 UTC (rev 3691)
@@ -19,7 +19,6 @@
 
 #include "rkrbackend.h"
 
-#include <QTimer>
 #include <QLocalSocket>
 
 #include "../version.h"
@@ -45,8 +44,8 @@
 	msleep (1000);
 }
 
-void RKRBackendTransmitter::flushOutput () {
-	// do not trace.
+void RKRBackendTransmitter::timerEvent (QTimerEvent *) {
+	// do not trace
 	flushOutput (false);
 }
 
@@ -65,10 +64,7 @@
 	connection->write ("\n");
 	connection->waitForBytesWritten ();
 
-	QTimer* flush_timer = new QTimer (this);
-	connect (flush_timer, SIGNAL (timeout()), this, SLOT (flushOutput()));
-	flush_timer->setInterval (200);
-	flush_timer->start ();
+	startTimer (200);	// calls flushOutput(false), periodically. See timerEvent()
 
 	exec ();
 }

Modified: trunk/rkward/rkward/rbackend/rkbackendtransmitter.h
===================================================================
--- trunk/rkward/rkward/rbackend/rkbackendtransmitter.h	2011-06-14 17:59:53 UTC (rev 3690)
+++ trunk/rkward/rkward/rbackend/rkbackendtransmitter.h	2011-06-16 17:22:24 UTC (rev 3691)
@@ -35,9 +35,8 @@
 	void writeRequest (RBackendRequest *request);
 	void requestReceived (RBackendRequest *request);
 	void handleTransmissionError (const QString &message);
-private slots:
-	void flushOutput ();
 private:
+	void timerEvent (QTimerEvent *event);
 	void flushOutput (bool force);
 	QList<RBackendRequest*> current_sync_requests;	// pointers to the request that we expect a reply for. Yes, internally, this can be several requests.
 	QString servername;


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