Skip to content

Commit

Permalink
Drop _PyThreadState_*Detached().
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Jul 19, 2023
1 parent 4c99023 commit d5b3aa4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 74 deletions.
5 changes: 0 additions & 5 deletions Include/internal/pycore_pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ PyAPI_FUNC(PyThreadState *) _PyThreadState_New(PyInterpreterState *interp);
PyAPI_FUNC(void) _PyThreadState_Bind(PyThreadState *tstate);
PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate);

extern void _PyThreadState_InitDetached(PyThreadState *, PyInterpreterState *);
extern void _PyThreadState_ClearDetached(PyThreadState *);
extern void _PyThreadState_BindDetached(PyThreadState *);
extern void _PyThreadState_UnbindDetached(PyThreadState *);

PyAPI_FUNC(PyObject*) _PyThreadState_GetDict(PyThreadState *tstate);

/* The implementation of sys._current_frames() Returns a dict mapping
Expand Down
69 changes: 0 additions & 69 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1640,75 +1640,6 @@ _PyThreadState_DeleteExcept(PyThreadState *tstate)
}


//-------------------------
// "detached" thread states
//-------------------------

void
_PyThreadState_InitDetached(PyThreadState *tstate, PyInterpreterState *interp)
{
_PyRuntimeState *runtime = interp->runtime;

HEAD_LOCK(runtime);
interp->threads.next_unique_id += 1;
uint64_t id = interp->threads.next_unique_id;
HEAD_UNLOCK(runtime);

init_threadstate(tstate, interp, id);
// We do not call add_threadstate().
}

void
_PyThreadState_ClearDetached(PyThreadState *tstate)
{
assert(!tstate->_status.bound);
assert(!tstate->_status.bound_gilstate);
assert(tstate->datastack_chunk == NULL);
assert(tstate->thread_id == 0);
assert(tstate->native_thread_id == 0);
assert(tstate->next == NULL);
assert(tstate->prev == NULL);

PyThreadState_Clear(tstate);
clear_datastack(tstate);
}

void
_PyThreadState_BindDetached(PyThreadState *tstate)
{
assert(!_Py_IsMainInterpreter(
current_fast_get(tstate->interp->runtime)->interp));
assert(_Py_IsMainInterpreter(tstate->interp));
bind_tstate(tstate);
/* Unlike _PyThreadState_Bind(), we do not modify gilstate TSS. */
}

void
_PyThreadState_UnbindDetached(PyThreadState *tstate)
{
assert(!_Py_IsMainInterpreter(
current_fast_get(tstate->interp->runtime)->interp));
assert(_Py_IsMainInterpreter(tstate->interp));
assert(tstate_is_alive(tstate));
assert(!tstate->_status.active);
assert(gilstate_tss_get(tstate->interp->runtime) != tstate);

unbind_tstate(tstate);

/* This thread state may be bound/unbound repeatedly,
so we must erase evidence that it was ever bound (or unbound). */
tstate->_status.bound = 0;
tstate->_status.unbound = 0;

/* We must fully unlink the thread state from any OS thread,
to allow it to be bound more than once. */
tstate->thread_id = 0;
#ifdef PY_HAVE_THREAD_NATIVE_ID
tstate->native_thread_id = 0;
#endif
}


//----------
// accessors
//----------
Expand Down

0 comments on commit d5b3aa4

Please sign in to comment.