Skip to content

Commit 1b76b0b

Browse files
committed
test: add a summary comment for tests
1 parent 883ac69 commit 1b76b0b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/test_scoped_critical_section.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class BoolWrapper {
4141

4242
#if defined(PYBIND11_HAS_BARRIER)
4343

44+
// Modifying the C/C++ members of a Python object from multiple threads requires a critical section
45+
// to ensure thread safety and data integrity.
46+
// These tests use a scoped critical section to ensure that the Python object is accessed in a
47+
// thread-safe manner.
48+
4449
void test_scoped_critical_section(const py::handle &cls) {
4550
auto barrier = std::barrier(2);
4651
auto bool_wrapper = cls(false);
@@ -113,7 +118,7 @@ void test_scoped_critical_section2(const py::handle &cls) {
113118
// Enter the critical section with two different objects.
114119
// This will ensure that the critical section is locked for both objects.
115120
py::scoped_critical_section lock{bool_wrapper1, bool_wrapper2};
116-
// At this point, objects is locked by this thread via the scoped_critical_section.
121+
// At this point, objects are locked by this thread via the scoped_critical_section.
117122
// This barrier will ensure that other threads wait until this thread has released
118123
// the critical section before proceeding.
119124
barrier.arrive_and_wait();

0 commit comments

Comments
 (0)