[Rd] Interrupting C++ code execution

Andrew Runnalls A.R.Runnalls at kent.ac.uk
Thu Apr 28 14:55:44 CEST 2011


Peter,

On 25/04/11 10:22, schattenpflanze at 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 have seen this thread sooner.

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.

However, it's fair to say that in using CXXR with a multi-threaded 
program you'll be on the bleeding edge...

Andrew



More information about the R-devel mailing list