Skip to content

Commit ed20cfc

Browse files
committed
Use a more appropriate function name
1 parent 3838ff1 commit ed20cfc

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

include/pybind11/detail/internals.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ inline PyThreadState *get_thread_state_unchecked() {
421421
/// We use this to figure out if there are or have been multiple subinterpreters active at any
422422
/// point. This must never go from true to false while any interpreter may be running in any
423423
/// thread!
424-
inline std::atomic<bool> &get_multiple_interpreters_seen() {
425-
static std::atomic<bool> multi(false);
424+
inline std::atomic_bool &has_seen_non_main_interpreter() {
425+
static std::atomic_bool multi(false);
426426
return multi;
427427
}
428428

@@ -650,7 +650,7 @@ class internals_pp_manager {
650650
/// acquire the GIL. Will never return nullptr.
651651
std::unique_ptr<InternalsType> *get_pp() {
652652
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
653-
if (get_multiple_interpreters_seen()) {
653+
if (has_seen_non_main_interpreter()) {
654654
// Whenever the interpreter changes on the current thread we need to invalidate the
655655
// internals_pp so that it can be pulled from the interpreter's state dict. That is
656656
// slow, so we use the current PyThreadState to check if it is necessary.
@@ -676,7 +676,7 @@ class internals_pp_manager {
676676
/// Drop all the references we're currently holding.
677677
void unref() {
678678
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
679-
if (get_multiple_interpreters_seen()) {
679+
if (has_seen_non_main_interpreter()) {
680680
last_istate_tls() = nullptr;
681681
internals_p_tls() = nullptr;
682682
return;
@@ -687,7 +687,7 @@ class internals_pp_manager {
687687

688688
void destroy() {
689689
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
690-
if (get_multiple_interpreters_seen()) {
690+
if (has_seen_non_main_interpreter()) {
691691
auto *tstate = get_thread_state_unchecked();
692692
// this could be called without an active interpreter, just use what was cached
693693
if (!tstate || tstate->interp == last_istate_tls()) {
@@ -796,7 +796,7 @@ inline void ensure_internals() {
796796
pybind11::detail::get_internals_pp_manager().unref();
797797
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
798798
if (PyInterpreterState_Get() != PyInterpreterState_Main()) {
799-
get_multiple_interpreters_seen() = true;
799+
has_seen_non_main_interpreter() = true;
800800
}
801801
#endif
802802
pybind11::detail::get_internals();

include/pybind11/embed.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ inline void initialize_interpreter(bool init_signal_handlers = true,
202202
#endif
203203

204204
// There is exactly one interpreter alive currently.
205-
detail::get_multiple_interpreters_seen() = false;
205+
detail::has_seen_non_main_interpreter() = false;
206206
}
207207

208208
/** \rst
@@ -242,12 +242,12 @@ inline void initialize_interpreter(bool init_signal_handlers = true,
242242
\endrst */
243243
inline void finalize_interpreter() {
244244
// get rid of any thread-local interpreter cache that currently exists
245-
if (detail::get_multiple_interpreters_seen()) {
245+
if (detail::has_seen_non_main_interpreter()) {
246246
detail::get_internals_pp_manager().unref();
247247
detail::get_local_internals_pp_manager().unref();
248248

249249
// We know there can be no other interpreter alive now
250-
detail::get_multiple_interpreters_seen() = false;
250+
detail::has_seen_non_main_interpreter() = false;
251251
}
252252

253253
// Re-fetch the internals pointer-to-pointer (but not the internals itself, which might not
@@ -266,7 +266,7 @@ inline void finalize_interpreter() {
266266
detail::get_local_internals_pp_manager().destroy();
267267

268268
// We know there is no interpreter alive now, so we can reset the multi-flag
269-
detail::get_multiple_interpreters_seen() = false;
269+
detail::has_seen_non_main_interpreter() = false;
270270
}
271271

272272
/** \rst

include/pybind11/gil_safe_call_once.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class gil_safe_call_once_and_store {
232232
// Indicator of fast path for single-interpreter case.
233233
bool is_last_storage_valid() const {
234234
return is_initialized_by_at_least_one_interpreter_
235-
&& !detail::get_multiple_interpreters_seen();
235+
&& !detail::has_seen_non_main_interpreter();
236236
}
237237

238238
// Get the unique key for this storage instance in the interpreter's state dict.

include/pybind11/subinterpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class subinterpreter {
109109

110110
// upon success, the new interpreter is activated in this thread
111111
result.istate_ = result.creation_tstate_->interp;
112-
detail::get_multiple_interpreters_seen() = true; // there are now many interpreters
112+
detail::has_seen_non_main_interpreter() = true; // there are now many interpreters
113113
detail::get_internals(); // initialize internals.tstate, amongst other things...
114114

115115
// In 3.13+ this state should be deleted right away, and the memory will be reused for

tests/test_with_catch/test_subinterpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void unsafe_reset_internals_for_single_interpreter() {
3131
py::detail::get_local_internals_pp_manager().unref();
3232

3333
// we know there are no other interpreters, so we can lower this. SUPER DANGEROUS
34-
py::detail::get_multiple_interpreters_seen() = false;
34+
py::detail::has_seen_non_main_interpreter() = false;
3535

3636
// now we unref the static global singleton internals
3737
py::detail::get_internals_pp_manager().unref();

0 commit comments

Comments
 (0)