The R Project SVN R

Rev

Rev 52103 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 52103 Rev 52104
Line 27... Line 27...
27
#include <Startup.h> /* rather cleanup ..*/
27
#include <Startup.h> /* rather cleanup ..*/
28
#include <Rconnections.h>
28
#include <Rconnections.h>
29
#include <Rinterface.h>
29
#include <Rinterface.h>
30
#include <R_ext/GraphicsEngine.h> /* for GEonExit */
30
#include <R_ext/GraphicsEngine.h> /* for GEonExit */
31
#include <Rmath.h> /* for imax2 */
31
#include <Rmath.h> /* for imax2 */
32
#if  !( defined(HAVE_AQUA) || defined(Win32) )
-
 
33
#include <R_ext/eventloop.h> /* for R_PolledEvents */
-
 
34
#endif
-
 
35
 
32
 
36
#ifndef min
33
#ifndef min
37
#define min(a, b) (a<b?a:b)
34
#define min(a, b) (a<b?a:b)
38
#endif
35
#endif
39
 
36
 
Line 102... Line 99...
102
{
99
{
103
    R_CheckStack();
100
    R_CheckStack();
104
 
101
 
105
    /* Don't do any processing of interrupts, timing limits, or other
102
    /* Don't do any processing of interrupts, timing limits, or other
106
       asynchronous events if interrupts are suspended. */
103
       asynchronous events if interrupts are suspended. */
107
    if (R_interrupts_suspended)
104
    if (R_interrupts_suspended) return;
108
	return;
-
 
109
 
105
 
110
    /* This is the point where GUI systems need to do enough event
106
    /* This is the point where GUI systems need to do enough event
111
       processing to determine whether there is a user interrupt event
107
       processing to determine whether there is a user interrupt event
112
       pending.  Need to be careful not to do too much event
108
       pending.  Need to be careful not to do too much event
113
       processing though: if event handlers written in R are allowed
109
       processing though: if event handlers written in R are allowed
114
       to run at this point then we end up with concurrent R
110
       to run at this point then we end up with concurrent R
115
       evaluations and that can cause problems until we have proper
111
       evaluations and that can cause problems until we have proper
116
       concurrency support. LT */
112
       concurrency support. LT */
117
#if defined(HAVE_AQUA) || defined(Win32)
-
 
118
    R_ProcessEvents();
-
 
119
#else
-
 
120
    R_PolledEvents();
-
 
121
    /* the same code is in R_ProcessEvents on Windows and AQUA */
-
 
122
    if (cpuLimit > 0.0 || elapsedLimit > 0.0) {
-
 
123
	double cpu, data[5];
-
 
124
	R_getProcTime(data);
-
 
125
	cpu = data[0] + data[1] + data[3] + data[4];
-
 
126
	if (elapsedLimit > 0.0 && data[2] > elapsedLimit) {
-
 
127
	    cpuLimit = elapsedLimit = -1;
-
 
128
	    if (elapsedLimit2 > 0.0 && data[2] > elapsedLimit2) {
-
 
129
		elapsedLimit2 = -1.0;
-
 
130
		error(_("reached session elapsed time limit"));
-
 
131
	    } else
-
 
132
		error(_("reached elapsed time limit"));
-
 
133
	}
113
 
134
	if (cpuLimit > 0.0 && cpu > cpuLimit) {
-
 
135
	    cpuLimit = elapsedLimit = -1;
-
 
136
	    if (cpuLimit2 > 0.0 && cpu > cpuLimit2) {
-
 
137
		cpuLimit2 = -1.0;
-
 
138
		error(_("reached session CPU time limit"));
114
    R_ProcessEvents(); /* Also processes timing limits */
139
	    } else
115
#ifndef Win32
140
		error(_("reached CPU time limit"));
-
 
141
	}
-
 
142
    }
-
 
143
    if (R_interrupts_pending)
116
    if (R_interrupts_pending) onintr();
144
	onintr();
117
#endif
145
#endif /* Aqua or Win32 */
-
 
146
}
118
}
147
 
119
 
148
void onintr()
120
void onintr()
149
{
121
{
150
    if (R_interrupts_suspended) {
122
    if (R_interrupts_suspended) {