[Rd] Interrupting C++ code execution

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Apr 25 20:17:57 CEST 2011


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 use.

Here's another option which is probably not recommendable for general use, 
since it is not part of the documented API:

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/GraphicsDevice.h also has 
R_interrupts_suspended, which you may or may not want to take into account, 
depending on your use-case.

BTW, being able to check for a pending interrupt or to schedule an interrupt 
from a separate thread is something that can come in handy in GUI development 
as well, and personally, I would appreciate, if there was some slightly more 
official support for this.

Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20110425/0be7c269/attachment.bin>


More information about the R-devel mailing list