How to assert if a std::mutex is locked?

前端 未结 7 1560
难免孤独
难免孤独 2020-12-03 13:30

With GCC 4.8.2 (on Linux/Debian/Sid 64 bits) -or GCC 4.9 when available - in C++11- I have some mutex

std::mutex gmtx;

actually, it is

7条回答
  •  借酒劲吻你
    2020-12-03 14:02

    Try atomic (e.g. atomic or atomic), which has a nice load function that will do what you want, as well as other nice functions like compare_exchange_strong.

提交回复
热议问题