[rkward-cvs] rkward/rkward/rbackend rembedinternal.cpp,1.28,1.29 rembedinternal.h,1.16,1.17 rinterface.cpp,1.38,1.39 rthread.cpp,1.27,1.28 rthread.h,1.20,1.21

Thomas Friedrichsmeier tfry at users.sourceforge.net
Thu Nov 3 19:34:32 UTC 2005


Update of /cvsroot/rkward/rkward/rkward/rbackend
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1930/rkward/rbackend

Modified Files:
	rembedinternal.cpp rembedinternal.h rinterface.cpp rthread.cpp 
	rthread.h 
Log Message:
Allow (hopefully) safe immediate interruption of running commands

Index: rthread.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rthread.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** rthread.h	3 Nov 2005 15:24:56 -0000	1.20
--- rthread.h	3 Nov 2005 19:34:29 -0000	1.21
***************
*** 150,153 ****
--- 150,158 ----
  /** current length of output. Used so we can flush every once in a while, if output becomes too long */
  	int out_buf_len;
+ 
+ /** interrupt processing of the current command. This is much like the user pressing Ctrl+C in a terminal with R. This is probably the only non-portable function in RThread, but I can't see a good way around placing it here, or to make it portable. */
+ 	void interruptProcessing (bool interrupt);
+ 
+ 	Qt::HANDLE thread_id;
  protected:
  /** the main loop. See \ref RThread for a more detailed description */

Index: rembedinternal.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rembedinternal.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** rembedinternal.h	3 Nov 2005 15:24:56 -0000	1.16
--- rembedinternal.h	3 Nov 2005 19:34:29 -0000	1.17
***************
*** 140,146 ****
  	static REmbedInternal *this_pointer;
  
- /** interrupt processing of the current command. This is much like the user pressing Ctrl+C in a terminal with R. */
- 	void interruptProcessing (bool interrupt);
- 
  /** Flags used to classify output. */
  //	static bool output_is_warning;
--- 140,143 ----

Index: rembedinternal.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rembedinternal.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** rembedinternal.cpp	3 Nov 2005 15:24:56 -0000	1.28
--- rembedinternal.cpp	3 Nov 2005 19:34:29 -0000	1.29
***************
*** 35,39 ****
  #include <stdlib.h>
  #include <string.h>
! 
  #include <math.h>
  
--- 35,41 ----
  #include <stdlib.h>
  #include <string.h>
! //#include <sys/types.h>
! //#include <signal.h>
! //#include <unistd.h>
  #include <math.h>
  
***************
*** 45,48 ****
--- 47,51 ----
  extern void Rf_PrintWarnings (void);
  extern int R_CollectWarnings;
+ extern int R_interrupts_pending;
  }
  
***************
*** 521,531 ****
  }
  
- void REmbedInternal::interruptProcessing (bool interrupt) {
- 	extern int R_interrupts_pending;
- 	if (interrupt) {
- 		R_interrupts_pending = 1;
- 	} else {
- 		R_interrupts_pending = 0;
- 	}
- }
  
--- 524,526 ----

Index: rthread.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rthread.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** rthread.cpp	3 Nov 2005 15:24:56 -0000	1.27
--- rthread.cpp	3 Nov 2005 19:34:29 -0000	1.28
***************
*** 31,34 ****
--- 31,36 ----
  #include <qapplication.h>
  
+ #include <signal.h>		// needed for pthread_kill
+ 
  #define MAX_BUF_LENGTH 1000
  
***************
*** 48,53 ****
--- 50,68 ----
  }
  
+ void RThread::interruptProcessing (bool interrupt) {
+ // TODO: find a good #ifdef to use the uncommented version below, if on a system without pthreads
+ 	if (interrupt) {
+ 		pthread_kill (thread_id, SIGINT);
+ 	}
+ /*	if (interrupt) {
+ 		R_interrupts_pending = 1;
+ 	} else {
+ 		R_interrupts_pending = 0;
+ 	} */
+ }
+ 
  void RThread::run () {
  	RK_TRACE (RBACKEND);
+ 	thread_id = currentThread ();
  	locked = Startup;
  	killed = false;
***************
*** 87,91 ****
  			if (killed) {
  				shutdown (false);
! 				MUTEX_UNLOCK
  				return;
  			}
--- 102,106 ----
  			if (killed) {
  				shutdown (false);
! 				MUTEX_UNLOCK;
  				return;
  			}

Index: rinterface.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rinterface.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** rinterface.cpp	3 Nov 2005 15:24:56 -0000	1.38
--- rinterface.cpp	3 Nov 2005 19:34:29 -0000	1.39
***************
*** 47,54 ****
  #include <qtimer.h>
  
- #include <stdlib.h>
- #include <sys/types.h>
- #include <signal.h>
- 
  // update output (for immediate output commands) at least this often:
  #define FLUSH_INTERVAL 50
--- 47,50 ----





More information about the rkward-tracker mailing list