Deepayan Sarkar
2007-May-31 20:13 UTC
[Rd] Calling R_PolledEvents from R_CheckUserInterrupt
On 5/5/07, Luke Tierney <luke at 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 */
Robert Gentleman
2007-May-31 21:48 UTC
[Rd] Calling R_PolledEvents from R_CheckUserInterrupt
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 at 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