Re: [Rd] interrupting native code

2008-05-21 Thread Luke Tierney
If you are using an external pointer you can register a finalizer that does the cleanup at gc time in case of an abnormal exit. Otherwise you should for now be able to use R_ToplevelExec tigether with R_CheckUserInterrupt as I suggested previously. Best, luke On Wed, 21 May 2008, Kjell Konis w

Re: [Rd] interrupting native code

2008-05-21 Thread Kjell Konis
I have a structure from a library that I am using an external pointer to keep track of. The methods in this library (lp_solve) have the facility to call a function periodically and I would like to use R_ProcessEvents. The problem is that if an interrupt is requested then R returns to the co

Re: [Rd] interrupting native code

2008-05-20 Thread Luke Tierney
On Tue, 20 May 2008, Kjell Konis wrote: I would actually prefer a mechanism that simply returns a flag indicating that an interrupt has been requested. Then I would be able to clean up and return on my own - no longjmp required. Whether that makes sense depends on why the jump is being taken.

Re: [Rd] interrupting native code

2008-05-20 Thread Simon Urbanek
On May 20, 2008, at 10:58 AM, Kjell Konis wrote: I would actually prefer a mechanism that simply returns a flag indicating that an interrupt has been requested. Then I would be able to clean up and return on my own - no longjmp required. Also, it would be useful if there was a function sim

Re: [Rd] interrupting native code

2008-05-20 Thread Kjell Konis
I would actually prefer a mechanism that simply returns a flag indicating that an interrupt has been requested. Then I would be able to clean up and return on my own - no longjmp required. Also, it would be useful if there was a function similar to R_ProcessEvents that only dealt with keepi

Re: [Rd] interrupting native code

2008-05-16 Thread Luke Tierney
I'm not sure you can make this work as some of the things needed either are or should be private to the core implementation and not available to package code. In any case I would not recommend this approach for two reasons. First, details of what happens in interrupt checking are subject to chan

Re: [Rd] interrupting native code

2008-05-16 Thread Prof Brian Ripley
On Fri, 16 May 2008, Kjell Konis wrote: You mean something like this (I return 1 instead of calling onintr())? Will HAVE_AQUA and Win32 be appropriately defined when building my package (I can't see how to check with R CMD config)? HAVE_AQUA is in Rconfig.h, and WIN32 (not Win32) is defined f

Re: [Rd] interrupting native code

2008-05-16 Thread Kjell Konis
You mean something like this (I return 1 instead of calling onintr())? Will HAVE_AQUA and Win32 be appropriately defined when building my package (I can't see how to check with R CMD config)? int My_CheckUserInterrupt(void) { R_CheckStack(); #if ( defined(HAVE_AQUA) ) /* R_ProcessEve

Re: [Rd] interrupting native code

2008-05-16 Thread Prof Brian Ripley
On Fri, 16 May 2008, Kjell Konis wrote: The problem is that my package uses an external pointer to keep track of a structure created by the lp_solve library. If I use R_CheckUserInterrupt in the lp_solve abort function it leaves the structure in a messed-up state after an interrupt occurs. I a

Re: [Rd] interrupting native code

2008-05-16 Thread Kjell Konis
The problem is that my package uses an external pointer to keep track of a structure created by the lp_solve library. If I use R_CheckUserInterrupt in the lp_solve abort function it leaves the structure in a messed-up state after an interrupt occurs. I am not even able to free the memory al

Re: [Rd] interrupting native code

2008-05-15 Thread Prof Brian Ripley
How is R_interrupts_pending going to be set? It is set in the interrupt handler for SIGINT, but that is not the only way to indicate an interrupt, and it is not necessarily available to users of GUIs and embedded R. Without servicing the GUIs all interaction will be dead, including sending a