Talk:cpp/thread/latch/~latch
From cppreference.com
The note of this page really confused me. How could a latch work if it were to invoke undefined behavior whenever a member function may be concurrently called? Based on the information provided in cpp/thread/latch, I suppose that only the destructor itself is considered unsafe to be called concurrently. The note is rather misleading. Yaossg (talk) 02:31, 29 January 2025 (PST)
- I agree it is confusing. The spec wording is https://eel.is/c++draft/thread.coord#thread.latch.class-2 "Concurrent invocations of the member functions of latch, other than its destructor, do not introduce data races.", which made its first appearance in wg21.link/p0666r1 (it's not there in p0666r0). Back then there also used to be dedicated wording about what happens if destructor is called concurrently with other member functions, but it was dropped in wg21.link/p1135r6 based on wg21.link/p1633 which sort of feels like it leaves that situation undefined, but doesn't mean it's a race. --Cubbi (talk) 09:02, 29 January 2025 (PST)