https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102962

--- Comment #2 from Marco Mengelkoch <Marco.Mengelkoch1 at ibm dot com> ---
> No, that's not a safe assumption at all. Libstdc++ uses the platform's 
> pthread types, it doesn't define them itself.

I would understand if just the order is different or if one is much faster than
the other. But on linux, this example code waits for an unlimited amount of
time, while it finishes quickly on windows. And it still looks like the code is
valid.

To make it work as on windows, I would need an additional unique lock.

While I would prefer the behavior of windows, it seems that the documentation
doesn't look accurate for windows

> // https://en.cppreference.com/w/cpp/thread/shared_mutex
> If one thread has acquired the shared lock (through lock_shared, 
> try_lock_shared), no other thread can acquire the exclusive lock, but can 
> acquire the shared lock.

On windows, no shared lock can be acquired anymore once a UniqueLock requested
a lock.

Reply via email to