Re: [Rd] Calling R_PolledEvents from R_CheckUserInterrupt

From: Robert Gentleman <rgentlem_at_fhcrc.org>
Date: Thu, 31 May 2007 14:48:25 -0700

should be there shortly - I have no way of testing windows (right now, at least), so hopefully Duncan M will have time to take a look

Deepayan Sarkar wrote:
> On 5/5/07, Luke Tierney <luke@stat.uiowa.edu> wrote:
>
> [...]
>

>> However, R_PolledEvents is only called from a limited set of places
>> now (including the socket reading code to keep things responsive
>> during blocking reads).  But it is not called from the interupt
>> checking code, which means if a user does something equivalent to
>>
>>     while (TRUE) {}
>>
>> there is not point where events get looked at to see a user interrupt
>> action. The current definition of R_CheckUserInterrupt is
>>
>> void R_CheckUserInterrupt(void)
>> {
>>      R_CheckStack();
>>      /* This is the point where GUI systems need to do enough event
>>         processing to determine whether there is a user interrupt event
>>         pending.  Need to be careful not to do too much event
>>         processing though: if event handlers written in R are allowed
>>         to run at this point then we end up with concurrent R
>>         evaluations and that can cause problems until we have proper
>>         concurrency support. LT */
>> #if  ( defined(HAVE_AQUA) || defined(Win32) )
>>      R_ProcessEvents();
>> #else
>>      if (R_interrupts_pending)
>>          onintr();
>> #endif /* Win32 */
>> }
>>
>> So only on Windows or Mac do we do event processing.  We could add a
>> R_PolledEvents() call in the #else bit to support this, though the
>> cautions in the comment do need to be kept in mind.

>
> I have been using the following patch to src/main/errors.c for a while
> without any obvious ill effects. Could we add this to r-devel (with
> necessary changes for Windows, if any)?
>
> -Deepayan
>
> Index: errors.c
> ===================================================================
> --- errors.c (revision 41764)
> +++ errors.c (working copy)
> @@ -39,6 +39,8 @@
> #include <R_ext/GraphicsEngine.h> /* for GEonExit */
> #include <Rmath.h> /* for imax2 */
>
> +#include <R_ext/eventloop.h>
> +
> #ifndef min
> #define min(a, b) (a<b?a:b)
> #endif
> @@ -117,6 +119,8 @@
> #if ( defined(HAVE_AQUA) || defined(Win32) )
> R_ProcessEvents();
> #else
> + R_PolledEvents();
> if (R_interrupts_pending)
> onintr();
> #endif /* Win32 */
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
-- 
Robert Gentleman, PhD
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
PO Box 19024
Seattle, Washington 98109-1024
206-667-7700
rgentlem_at_fhcrc.org

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu 31 May 2007 - 23:11:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 May 2007 - 23:34:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.