diff options
| author | Guido van Rossum <guido@python.org> | 2001-01-23 01:46:06 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2001-01-23 01:46:06 +0000 |
| commit | 8ea2265b0da031a92be3332d1aa934ea2f13b834 (patch) | |
| tree | 211a3aa8d11645b608d5d35c966d7e2c02227e19 /Python/pystate.c | |
| parent | aeee4368ae979ca0434383d3c49fe2e050fcb44b (diff) | |
| download | cpython-8ea2265b0da031a92be3332d1aa934ea2f13b834.tar.gz | |
Add a new API, PyThreadState_DeleteCurrent() that combines
PyThreadState_Delete() and PyEval_ReleaseLock(). It is only defined
if WITH_THREAD is defined.
Diffstat (limited to 'Python/pystate.c')
| -rw-r--r-- | Python/pystate.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 0651ab016f..8e5896a44f 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -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) { |
