File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -627,15 +627,23 @@ TEST_CASE("Threads") {
627
627
628
628
{
629
629
py::gil_scoped_release gil_release{};
630
+ #if defined(Py_GIL_DISABLED) && PY_VERSION_HEX < 0x030E0000
631
+ std::mutex mutex;
632
+ #endif
630
633
631
634
auto threads = std::vector<std::thread>();
632
635
for (auto i = 0 ; i < num_threads; ++i) {
633
636
threads.emplace_back ([&]() {
634
637
py::gil_scoped_acquire gil{};
635
638
#ifdef Py_GIL_DISABLED
639
+ # if PY_VERSION_HEX < 0x030E0000
640
+ std::lock_guard<std::mutex> lock (mutex);
641
+ locals[" count" ] = locals[" count" ].cast <int >() + 1 ;
642
+ # else
636
643
Py_BEGIN_CRITICAL_SECTION (locals.ptr ());
637
644
locals[" count" ] = locals[" count" ].cast <int >() + 1 ;
638
645
Py_END_CRITICAL_SECTION ();
646
+ # endif
639
647
#else
640
648
locals[" count" ] = locals[" count" ].cast <int >() + 1 ;
641
649
#endif
You can’t perform that action at this time.
0 commit comments