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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Nov 19 11:08:05 UTC 2010


Revision: 3194
          http://rkward.svn.sourceforge.net/rkward/?rev=3194&view=rev
Author:   tfry
Date:     2010-11-19 11:08:05 +0000 (Fri, 19 Nov 2010)

Log Message:
-----------
Make command interruption work (NOTE: this is still not quite correct, but not any buggier than currently released versions).

Modified Paths:
--------------
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.cpp
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkbackendtransmitter.cpp
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackend.cpp
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_backend.h
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_frontend.cpp
    branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_shared.h

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-18 15:32:05 UTC (rev 3193)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.cpp	2010-11-19 11:08:05 UTC (rev 3194)
@@ -204,7 +204,7 @@
 
 	if (command->type () & RCommand::QuitCommand) backend_dead = true;
 
-	if ((command->status & RCommand::Canceled) || (command == running_command_canceled)) {
+	if (command->status & RCommand::Canceled) {
 		command->status |= RCommand::HasError;
 		ROutput *out = new ROutput;
 		out->type = ROutput::Error;
@@ -416,6 +416,8 @@
 	if (!(command->type () & RCommand::Sync)) {
 		command->status |= RCommand::Canceled;
 		if (command->type () && RCommand::Running) {
+#warning This assumption is wrong. Fix command cancellation.
+// In particular, the backend may contain several commands at once. We should tell the backend, exactly which commands to cancel
 			if (running_command_canceled != command) {
 				RK_ASSERT (!running_command_canceled);
 				locked |= Cancel;

Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkbackendtransmitter.cpp
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkbackendtransmitter.cpp	2010-11-18 15:32:05 UTC (rev 3193)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkbackendtransmitter.cpp	2010-11-19 11:08:05 UTC (rev 3194)
@@ -84,21 +84,26 @@
 void RKRBackendTransmitter::requestReceived (RBackendRequest* request) {
 	RK_TRACE (RBACKEND);
 
-	if (current_sync_requests.isEmpty ()) {
-		RK_ASSERT (false);
-		return;
-	}
+	// first check for requests which originated in the frontend
+	if (request->type == RBackendRequest::Interrupt) {
+		RKRBackendProtocolBackend::interruptProcessing ();
+	// requests which originated in the backend below this line
+	} else {
+		if (current_sync_requests.isEmpty ()) {
+			RK_ASSERT (false);
+			return;
+		}
 
-	RBackendRequest* current_sync_request = current_sync_requests.takeFirst ();
-	if (current_sync_request->type == RBackendRequest::Output) {
-		delete current_sync_request;	// this was just our internal request
-		delete request;
-	} else {
-		current_sync_request->mergeReply (request);
-		delete request;
-		current_sync_request->done = true;
+		RBackendRequest* current_sync_request = current_sync_requests.takeFirst ();
+		if (current_sync_request->type == RBackendRequest::Output) {
+			delete current_sync_request;	// this was just our internal request
+		} else {
+			current_sync_request->mergeReply (request);
+			current_sync_request->done = true;
+		}
+		RK_DO (qDebug ("Expecting replies for %d requests (popped %p)", current_sync_requests.size (), current_sync_request), RBACKEND, DL_DEBUG);
 	}
-	RK_DO (qDebug ("Expecting replies for %d requests (popped %p)", current_sync_requests.size (), current_sync_request), RBACKEND, DL_DEBUG);
+	delete request;
 }
 
 void RKRBackendTransmitter::flushOutput (bool force) {
@@ -117,7 +122,7 @@
 void RKRBackendTransmitter::handleTransmissionError (const QString &message) {
 	RK_TRACE (RBACKEND);
 
-	RK_DO (qDebug (qPrintable ("Transmission error " + message)), RBACKEND, DL_ERROR);
+	RK_DO (qDebug ("%s", qPrintable ("Transmission error " + message)), RBACKEND, DL_ERROR);
 	RKRBackend::tryToDoEmergencySave ();
 }
 

Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackend.cpp
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackend.cpp	2010-11-18 15:32:05 UTC (rev 3193)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackend.cpp	2010-11-19 11:08:05 UTC (rev 3194)
@@ -722,7 +722,7 @@
 		// NOTE: if R_interrupts_pending stops being exported one day, we might be able to use R_CheckUserInterrupt() inside an R_ToplevelExec() to find out, whether an interrupt was still pending.
 		if (!R_interrupts_pending) {
 			RKRBackend::repl_status.interrupted = false;
-			if (!RKRBackend::repl_status.user_command_status == RKRBackend::RKReplStatus::ReplIterationKilled) {	// was interrupted only to step out of the repl iteration
+			if (RKRBackend::repl_status.user_command_status != RKRBackend::RKReplStatus::ReplIterationKilled) {	// was interrupted only to step out of the repl iteration
 				foreach (RCommandProxy *command, RKRBackend::this_pointer->all_current_commands) command->status |= RCommand::Canceled;
 				RK_DO (qDebug ("interrupted"), RBACKEND, DL_DEBUG);
 			}
@@ -1209,7 +1209,7 @@
 		if (new_globalenv_toplevel_names.count () != global_env_toplevel_names.count ()) {
 			globalenv_update_needed = true;
 		} else {
-			for (unsigned int i = 0; i < new_globalenv_toplevel_names.count (); ++i) {
+			for (int i = 0; i < new_globalenv_toplevel_names.count (); ++i) {
 				// order is not important in the symbol list
 				if (!global_env_toplevel_names.contains (new_globalenv_toplevel_names[i])) {
 					globalenv_update_needed = true;

Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_backend.h
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_backend.h	2010-11-18 15:32:05 UTC (rev 3193)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_backend.h	2010-11-19 11:08:05 UTC (rev 3194)
@@ -33,6 +33,7 @@
 friend class RKRBackendProtocolFrontend;
 friend class RKRBackend;
 friend class RKRBackendThread;
+friend class RKRBackendTransmitter;
 	void sendRequest (RBackendRequest *request);
 	static void msleep (int delay);
 	static void interruptProcessing ();

Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_frontend.cpp
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_frontend.cpp	2010-11-18 15:32:05 UTC (rev 3193)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_frontend.cpp	2010-11-19 11:08:05 UTC (rev 3194)
@@ -95,8 +95,8 @@
 	RK_ASSERT (!RKRBackendProtocolBackend::inRThread ());
 	RKRBackendProtocolBackend::interruptProcessing ();
 #else
-//	kill (SIGUSR1, pid_of_it);
-#warning will not work on windows!
+	RBackendRequest *req = new RBackendRequest (false, RBackendRequest::Interrupt);
+	qApp->postEvent (RKFrontendTransmitter::instance (), new RKRBackendEvent (req));
 #endif
 }
 

Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_shared.h
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_shared.h	2010-11-18 15:32:05 UTC (rev 3193)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrbackendprotocol_shared.h	2010-11-19 11:08:05 UTC (rev 3194)
@@ -45,6 +45,7 @@
 		SetParamsFromBackend,
 #ifndef RKWARD_THREADED
 		Output,		/**< A piece of output. Note: If the backend runs in a single process, output is handled in a pull fashion, instead of using requests. */
+		Interrupt,	/**< Interrupt evaluation. This request type originates in the frontend, not the backend (the only one so far). */
 #endif
 		OtherRequest		/**< Any other type of request. Note: which requests are in the enum, and which are not has mostly historical reasons. @see params */
 	};


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