]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add a new API, PyThreadState_DeleteCurrent() that combines
authorGuido van Rossum <guido@python.org>
Tue, 23 Jan 2001 01:46:06 +0000 (01:46 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 23 Jan 2001 01:46:06 +0000 (01:46 +0000)
PyThreadState_Delete() and PyEval_ReleaseLock().  It is only defined
if WITH_THREAD is defined.

Include/pystate.h
Python/pystate.c

index be5649798920c355595b48631d2d09179df0457c..27ffe32437f41a3606853426468bd35f60620bfb 100644 (file)
@@ -66,6 +66,9 @@ DL_IMPORT(void) PyInterpreterState_Delete(PyInterpreterState *);
 DL_IMPORT(PyThreadState *) PyThreadState_New(PyInterpreterState *);
 DL_IMPORT(void) PyThreadState_Clear(PyThreadState *);
 DL_IMPORT(void) PyThreadState_Delete(PyThreadState *);
+#ifdef WITH_THREAD
+DL_IMPORT(void) PyThreadState_DeleteCurrent(void);
+#endif
 
 DL_IMPORT(PyThreadState *) PyThreadState_Get(void);
 DL_IMPORT(PyThreadState *) PyThreadState_Swap(PyThreadState *);
index 0651ab016fd5098fc852af35b68cd34e5ad85c85..8e5896a44fd1ea27f207557ae0aa2d508a5e5415 100644 (file)
@@ -157,15 +157,14 @@ PyThreadState_Clear(PyThreadState *tstate)
 }
 
 
-void
-PyThreadState_Delete(PyThreadState *tstate)
+/* Common code for PyThreadState_Delete() and PyThreadState_DeleteCurrent() */
+static void
+tstate_delete_common(PyThreadState *tstate)
 {
        PyInterpreterState *interp;
        PyThreadState **p;
        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)
                Py_FatalError("PyThreadState_Delete: NULL interp");
@@ -183,6 +182,30 @@ PyThreadState_Delete(PyThreadState *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 */
+
+
 PyThreadState *
 PyThreadState_Get(void)
 {