[Python-checkins] CVS: python/dist/src/Python pystate.c,2.15,2.16

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 22 Jan 2001 17:46:08 -0800


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

Modified Files:
	pystate.c 
Log Message:
Add a new API, PyThreadState_DeleteCurrent() that combines
PyThreadState_Delete() and PyEval_ReleaseLock().  It is only defined
if WITH_THREAD is defined.


Index: pystate.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pystate.c,v
retrieving revision 2.15
retrieving revision 2.16
diff -C2 -r2.15 -r2.16
*** pystate.c	2000/09/02 09:16:15	2.15
--- pystate.c	2001/01/23 01:46:06	2.16
***************
*** 158,163 ****
  
  
! void
! PyThreadState_Delete(PyThreadState *tstate)
  {
  	PyInterpreterState *interp;
--- 158,164 ----
  
  
! /* Common code for PyThreadState_Delete() and PyThreadState_DeleteCurrent() */
! static void
! tstate_delete_common(PyThreadState *tstate)
  {
  	PyInterpreterState *interp;
***************
*** 165,170 ****
  	if (tstate == NULL)
  		Py_FatalError("PyThreadState_Delete: NULL tstate");
- 	if (tstate == _PyThreadState_Current)
- 		Py_FatalError("PyThreadState_Delete: tstate is still current");
  	interp = tstate->interp;
  	if (interp == NULL)
--- 166,169 ----
***************
*** 182,185 ****
--- 181,208 ----
  	PyMem_DEL(tstate);
  }
+ 
+ 
+ void
+ PyThreadState_Delete(PyThreadState *tstate)
+ {
+ 	if (tstate == _PyThreadState_Current)
+ 		Py_FatalError("PyThreadState_Delete: tstate is still current");
+ 	tstate_delete_common(tstate);
+ }
+ 
+ 
+ #ifdef WITH_THREAD
+ void
+ PyThreadState_DeleteCurrent()
+ {
+ 	PyThreadState *tstate = _PyThreadState_Current;
+ 	if (tstate == NULL)
+ 		Py_FatalError(
+ 			"PyThreadState_DeleteCurrent: no current tstate");
+ 	_PyThreadState_Current = NULL;
+ 	tstate_delete_common(tstate);
+ 	PyEval_ReleaseLock();
+ }
+ #endif /* WITH_THREAD */