|
|
|
@ -65,8 +65,9 @@ public:
@@ -65,8 +65,9 @@ public:
|
|
|
|
|
if (!tstate) { |
|
|
|
|
tstate = PyThreadState_New(internals.istate); |
|
|
|
|
#if !defined(NDEBUG) |
|
|
|
|
if (!tstate) |
|
|
|
|
if (!tstate) { |
|
|
|
|
pybind11_fail("scoped_acquire: could not create thread state!"); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
tstate->gilstate_counter = 0; |
|
|
|
|
PYBIND11_TLS_REPLACE_VALUE(internals.tstate, tstate); |
|
|
|
@ -88,15 +89,18 @@ public:
@@ -88,15 +89,18 @@ public:
|
|
|
|
|
PYBIND11_NOINLINE void dec_ref() { |
|
|
|
|
--tstate->gilstate_counter; |
|
|
|
|
#if !defined(NDEBUG) |
|
|
|
|
if (detail::get_thread_state_unchecked() != tstate) |
|
|
|
|
if (detail::get_thread_state_unchecked() != tstate) { |
|
|
|
|
pybind11_fail("scoped_acquire::dec_ref(): thread state must be current!"); |
|
|
|
|
if (tstate->gilstate_counter < 0) |
|
|
|
|
} |
|
|
|
|
if (tstate->gilstate_counter < 0) { |
|
|
|
|
pybind11_fail("scoped_acquire::dec_ref(): reference count underflow!"); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
if (tstate->gilstate_counter == 0) { |
|
|
|
|
#if !defined(NDEBUG) |
|
|
|
|
if (!release) |
|
|
|
|
if (!release) { |
|
|
|
|
pybind11_fail("scoped_acquire::dec_ref(): internal error!"); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
PyThreadState_Clear(tstate); |
|
|
|
|
if (active) { |
|
|
|
|