[cfe-dev] thread-safety warnings, specifically try_acquire_capability

Bruce Stephens via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 18 01:36:50 PST 2018


I'm trying to use the annotations on some existing code, with (I
think) success, mostly. There's some code that conditionally locks
mutexes, and I note that's not supported so some code reorganisation
was needed.

What I can't seem to get to work is trylock(). I have some code which
does something like

    if (!mutex_.trylock()) {
       return;
    }
    ...
    mutex_.unlock();

and that doesn't work at all. I always seem to get complaints that
mutex_ might not be locked. Is this just an extension of the
unsupported nature of conditional locking? i.e., is there currently no
useful way to use the try_acquire_capability attribute (beyond
documentation)? (Not a horrible restriction for this code, but I'd
have thought it would be useful to mention it in the docs.)



More information about the cfe-dev mailing list