Skip to content

Commit 728a8d9

Browse files
committed
Remove PYBIND11_CAN_USE_THREAD_LOCAL
1 parent a912648 commit 728a8d9

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

include/pybind11/detail/common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,8 +1344,5 @@ constexpr
13441344
# define PYBIND11_BACKWARD_COMPATIBILITY_TP_DICTOFFSET
13451345
#endif
13461346

1347-
// TODO: determine which platforms cannot use thread_local.
1348-
#define PYBIND11_CAN_USE_THREAD_LOCAL 1
1349-
13501347
PYBIND11_NAMESPACE_END(detail)
13511348
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)

include/pybind11/detail/type_caster_base.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class loader_life_support {
4545
loader_life_support *parent = nullptr;
4646
std::unordered_set<PyObject *> keep_alive;
4747

48-
#if defined(PYBIND11_CAN_USE_THREAD_LOCAL)
4948
struct fake_thread_specific_storage {
5049
loader_life_support *instance = nullptr;
5150
loader_life_support *get() const { return instance; }
@@ -56,24 +55,16 @@ class loader_life_support {
5655
}
5756
};
5857
using loader_storage = fake_thread_specific_storage;
59-
#else
60-
using loader_storage = thread_specific_storage<loader_life_support>;
61-
#endif
6258

6359
static loader_storage &get_stack_top() {
64-
#if defined(PYBIND11_CAN_USE_THREAD_LOCAL)
65-
// Without this branch, loader_life_support destruction is a
66-
// significant cost per function call.
67-
//
6860
// Observation: loader_life_support needs to be thread-local, but
6961
// we don't need to go to extra effort to keep it per-interpreter
7062
// (i.e., by putting it in internals) since function calls are
7163
// already isolated to a single interpreter.
64+
// This saves a significant cost per function call spent in
65+
// loader_life_support destruction.
7266
static thread_local fake_thread_specific_storage storage;
7367
return storage;
74-
#else
75-
return get_internals().loader_life_support_tls;
76-
#endif
7768
}
7869

7970
public:

0 commit comments

Comments
 (0)