From thomas.friedrichsmeier at ruhr-uni-bochum.de  Mon Apr 25 20:17:57 2011
From: thomas.friedrichsmeier at ruhr-uni-bochum.de (Thomas Friedrichsmeier)
Date: 25 Apr 2011 20:17:57 +0200
Subject: [Rd] Interrupting C++ code execution
In-Reply-To: <F1EAEEC8-7828-403F-BF2D-10A4F925B4E6@r-project.org>
References: <4DB53D47.7060903@arcor.de>
	<85607CA7-D76F-4210-9C6E-F3E9F26F7D0E@r-project.org>
	<F1EAEEC8-7828-403F-BF2D-10A4F925B4E6@r-project.org>
Message-ID: <201104252018.01541.thomas.friedrichsmeier@ruhr-uni-bochum.de>

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>


[Rd] Interrupting C++ code execution
Thomas Friedrichsmeier