[rkward-cvs] SF.net SVN: rkward:[3173] branches/2010_10_18_backend_restructuring_branch/ rkward/rbackend

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Nov 2 20:03:32 UTC 2010


Revision: 3173
          http://rkward.svn.sourceforge.net/rkward/?rev=3173&view=rev
Author:   tfry
Date:     2010-11-02 20:03:31 +0000 (Tue, 02 Nov 2010)

Log Message:
-----------
Minor performance tweak

Modified Paths:
--------------
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.h
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.cpp
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h

Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp	2010-11-02 12:26:58 UTC (rev 3172)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp	2010-11-02 20:03:31 UTC (rev 3173)
@@ -817,7 +817,6 @@
 
 // register our functions
 	R_CallMethodDef callMethods [] = {
-//		{ "rk.do.condition", (DL_FUNC) &doCondition, 1 },
 		{ "rk.do.error", (DL_FUNC) &doError, 1 },
 		{ "rk.do.command", (DL_FUNC) &doSubstackCall, 1 },
 		{ "rk.get.structure", (DL_FUNC) &doGetStructure, 4 },

Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.h
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.h	2010-11-02 12:26:58 UTC (rev 3172)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.h	2010-11-02 20:03:31 UTC (rev 3173)
@@ -2,7 +2,7 @@
                           rembedinternal  -  description
                              -------------------
     begin                : Sun Jul 25 2004
-    copyright            : (C) 2004, 2005, 2006, 2007, 2009 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2005, 2006, 2007, 2009, 2010 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 

Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.cpp
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.cpp	2010-11-02 12:26:58 UTC (rev 3172)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.cpp	2010-11-02 20:03:31 UTC (rev 3173)
@@ -85,6 +85,7 @@
 	startup_phase2_error = false;
 	command_logfile_mode = NotRecordingCommands;
 	previously_idle = false;
+	previous_command = 0;
 	locked = 0;
 
 	// create a fake init command
@@ -159,6 +160,15 @@
 	r_thread->start ();
 }
 
+void RInterface::popPreviousCommand () {
+	RK_TRACE (RBACKEND);
+
+	RK_ASSERT (previous_command == 0);
+	RK_ASSERT (!all_current_commands.isEmpty ());
+	previous_command = all_current_commands.takeLast ();
+	RCommandStack::currentStack ()->pop ();
+}
+
 void RInterface::tryNextCommand () {
 	RK_TRACE (RBACKEND);
 	if (!currentCommandRequest ()) return;
@@ -177,6 +187,7 @@
 				command->status |= RCommand::Failed;
 
 				// notify ourselves...
+				popPreviousCommand ();
 				handleCommandOut (new RCommandProxy (command));
 				return;
 			}
@@ -203,9 +214,8 @@
 	RK_TRACE (RBACKEND);
 
 	RK_ASSERT (proxy);
-	RK_ASSERT (!all_current_commands.isEmpty ());
-	RCommand *command = all_current_commands.takeLast ();
-	RCommandStack::currentStack ()->pop ();
+	RK_ASSERT (previous_command);
+	RCommand* command = previous_command;
 	proxy->mergeAndDelete (command);
 
 	#ifdef RKWARD_DEBUG
@@ -244,6 +254,7 @@
 	command->finished ();
 	RCommandStackModel::getModel ()->itemChange (command);
 	delete command;
+	previous_command = 0;
 }
 
 void RInterface::doNextCommand (RCommand *command) {
@@ -330,11 +341,13 @@
 	if (request->type == RBackendRequest::CommandOut) {
 		RCommandProxy *cproxy = request->command;
 
-		if (cproxy) handleCommandOut (cproxy);
-		// else: cproxy should only even be 0 in the very first cycle
-
+		// NOTE: the order of processing is: first try to submit the next command, then handle the old command.
+		// The reason for doing it this way, instead of the reverse, is that this allows the backend thread / process to continue working, concurrently
+		// NOTE: cproxy should only even be 0 in the very first cycle
+		if (cproxy) popPreviousCommand ();
 		command_requests.append (request);
 		tryNextCommand ();
+		if (cproxy) handleCommandOut (cproxy);
 	} else if (request->type == RBackendRequest::HistoricalSubstackRequest) {
 		processHistoricalSubstackRequest (request);
 	} else if ((request->type == RBackendRequest::Started)) {

Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h	2010-11-02 12:26:58 UTC (rev 3172)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h	2010-11-02 20:03:31 UTC (rev 3173)
@@ -104,11 +104,13 @@
 
 /** A list of all commands that have entered, and not yet left, the backend thread */
 	QList<RCommand*> all_current_commands;
+	RCommand* previous_command;
 /** NOTE: processsing R events while waiting for the next command may, conceivably, lead to new requests, which may also wait for sub-commands! Thus we keep a simple stack of requests. */
 	QList<RBackendRequest*> command_requests;
 	RBackendRequest* currentCommandRequest () const { return (command_requests.isEmpty () ? 0 : command_requests.last ()); };
 	void tryNextCommand ();
 	void doNextCommand (RCommand *command);
+	void popPreviousCommand ();
 	void handleCommandOut (RCommandProxy *proxy);
 	bool previously_idle;
 


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