[Python-checkins] python/dist/src/Python ceval.c,2.333,2.334 sysmodule.c,2.109,2.110

montanaro@users.sourceforge.net montanaro@users.sourceforge.net
Tue, 03 Sep 2002 13:10:47 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv1832/Python

Modified Files:
	ceval.c sysmodule.c 
Log Message:
replace thread state objects' ticker and checkinterval fields with two
globals, _Py_Ticker and _Py_CheckInterval.  This also implements Jeremy's
shortcut in Py_AddPendingCall that zeroes out _Py_Ticker.  This allows the
test in the main loop to only test a single value.

The gory details are at

    http://python.org/sf/602191



Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.333
retrieving revision 2.334
diff -C2 -d -r2.333 -r2.334
*** ceval.c	30 Aug 2002 13:09:50 -0000	2.333
--- ceval.c	3 Sep 2002 20:10:44 -0000	2.334
***************
*** 396,399 ****
--- 396,401 ----
  	pendingcalls[i].arg = arg;
  	pendinglast = j;
+ 
+ 	_Py_Ticker = 0;
  	things_to_do = 1; /* Signal main loop */
  	busy = 0;
***************
*** 466,469 ****
--- 468,475 ----
  static int unpack_iterable(PyObject *, int, PyObject **);
  
+ /* for manipulating the thread switch and periodic "stuff" - used to be
+    per thread, now just a pair o' globals */
+ int _Py_CheckInterval = 10;
+ volatile int _Py_Ticker = 10;
  
  PyObject *
***************
*** 670,675 ****
  		   Py_MakePendingCalls() above. */
  
! 		if (things_to_do || --tstate->ticker < 0) {
! 			tstate->ticker = tstate->interp->checkinterval;
  			if (things_to_do) {
  				if (Py_MakePendingCalls() < 0) {
--- 676,681 ----
  		   Py_MakePendingCalls() above. */
  
! 		if (--_Py_Ticker < 0) {
! 			_Py_Ticker = _Py_CheckInterval;
  			if (things_to_do) {
  				if (Py_MakePendingCalls() < 0) {

Index: sysmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v
retrieving revision 2.109
retrieving revision 2.110
diff -C2 -d -r2.109 -r2.110
*** sysmodule.c	3 Sep 2002 13:25:17 -0000	2.109
--- sysmodule.c	3 Sep 2002 20:10:45 -0000	2.110
***************
*** 353,358 ****
  sys_setcheckinterval(PyObject *self, PyObject *args)
  {
! 	PyThreadState *tstate = PyThreadState_Get();
! 	if (!PyArg_ParseTuple(args, "i:setcheckinterval", &tstate->interp->checkinterval))
  		return NULL;
  	Py_INCREF(Py_None);
--- 353,357 ----
  sys_setcheckinterval(PyObject *self, PyObject *args)
  {
! 	if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval))
  		return NULL;
  	Py_INCREF(Py_None);