Re: [Rd] Interrupting C++ code execution

2011-04-28 Thread peterhepperger
Andrew, > You may like to give CXXR a try > (http://www.cs.kent.ac.uk/projects/cxxr/). In CXXR the R interpreter is > written in C++, and a user interrupt is handled by throwing a C++ > exception, so the stack is unwound in an orderly fashion, destructors > are invoked, etc. Thank you for thi

Re: [Rd] Interrupting C++ code execution

2011-04-28 Thread Andrew Runnalls
Peter, On 25/04/11 10:22, schattenpfla...@arcor.de wrote: 1. Calling R_CheckUserInterrupt() interrupts immediately, so I have no possibility to exit my code gracefully. In particular, I suppose that objects created on the heap (e.g., STL containers) are not destructed properly. Sorry not to ha

Re: [Rd] Interrupting C++ code execution

2011-04-26 Thread Sean Robert McGuffee
Hi, I've been thinking about how to handle c++ threads that were started via Rcpp calls to some of my c++ libraries from R. My main obstacle is trying to make sure that users don't try to process files that are being generated by a thread before the thread finishes. One thing I am considering is ha

Re: [Rd] Interrupting C++ code execution

2011-04-26 Thread Simon Urbanek
On Apr 26, 2011, at 7:30 AM, schattenpfla...@arcor.de wrote: > I have tested the solutions suggested by Simon and Thomas on a Linux machine. > These are my findings: > >> On Windows you can look at the variable "UserBreak", available from >> Rembedded.h. Outside of Windows, you can look at R_in

Re: [Rd] Interrupting C++ code execution

2011-04-26 Thread schattenpflanze
I have tested the solutions suggested by Simon and Thomas on a Linux machine. These are my findings: On Windows you can look at the variable "UserBreak", available from Rembedded.h. Outside of Windows, you can look at R_interrupts_pending, available from R_ext/GraphicsDevice.h. R_ext/GraphicsDe

Re: [Rd] Interrupting C++ code execution

2011-04-25 Thread schattenpflanze
Dear Simon, thanks again for your explanations. Your previous e-mail clarified several points for me. Actually, it just came to me that there is a hack you could use. [...] That actually looks quite nice. At least when compared to my currently only alternative of not interrupting at all. I w

Re: [Rd] Interrupting C++ code execution

2011-04-25 Thread schattenpflanze
Thank you for your response, Simon. 1. Calling R_CheckUserInterrupt() interrupts immediately, so I have no possibility to exit my code gracefully. In particular, I suppose that objects created on the heap (e.g., STL containers) are not destructed properly. In general, you're responsible for the

Re: [Rd] Interrupting C++ code execution

2011-04-25 Thread Thomas Friedrichsmeier
On Monday 25 April 2011, Simon Urbanek wrote: > Actually, it just came to me that there is a hack you could use. The > problem with it is that it will eat all errors, even if they were not > yours (e.g. those resulting from events triggered the event loop), so I > would not recommend it for general

Re: [Rd] Interrupting C++ code execution

2011-04-25 Thread Simon Urbanek
Actually, it just came to me that there is a hack you could use. The problem with it is that it will eat all errors, even if they were not yours (e.g. those resulting from events triggered the event loop), so I would not recommend it for general use. But here we go: static void chkIntFn(void *d

Re: [Rd] Interrupting C++ code execution

2011-04-25 Thread Simon Urbanek
On Apr 25, 2011, at 11:09 AM, schattenpfla...@arcor.de wrote: > Thank you for your response, Simon. > >>> 1. Calling R_CheckUserInterrupt() interrupts immediately, so I have >>> no possibility to exit my code gracefully. In particular, I suppose >>> that objects created on the heap (e.g., STL co

Re: [Rd] Interrupting C++ code execution

2011-04-25 Thread Simon Urbanek
On Apr 25, 2011, at 5:22 AM, schattenpfla...@arcor.de wrote: > Hello, > > I am writing an R interface for one of my C++ programs. The computations in > C++ are very time consuming (several hours), so the user needs to be able to > interrupt them. Currently, the only way I found to do so is cal

[Rd] Interrupting C++ code execution

2011-04-25 Thread schattenpflanze
Hello, I am writing an R interface for one of my C++ programs. The computations in C++ are very time consuming (several hours), so the user needs to be able to interrupt them. Currently, the only way I found to do so is calling R_CheckUserInterrupt() frequently. Unfortunately, there are sever