Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>(1) I don't see any reason that signalling a condition variable has to be guarded by a mutex, from a data-race stand-point. Obviously, you have the possibility of receiving redundant notifications or losing notifications, but if this is an acceptable or recoverable error condition for your program, I don't believe there's anything in the standard that will make it illegal. The standard, of course, won't guard you against race conditions; it's the programmer's responsibility to make sure that race conditions are benign. (And, of course, it is essential that the programmer not put any "data races", which are defined very specifically in the standard but don't apply directly to synchronization primitives, or undefined behavior is summoned.)</p> <p>(2) I can't answer a question like this about the internal implementation of a standard library facility. It is, of course, the vendor's responsibility to provide library facilities that work correctly and meet the specification. This library's implementation may have some internal state that requires mutual exclusion to avoid corruption, or it may perform locking in order to avoid lost or redundant notifications. (Just because your program may tolerate them, doesn't mean arbitrary users of the library can, and in general I expect they can't.) It would just be speculation on my part what they're guarding with this mutex.</p> <p>(3) <code>condition_variable_any</code> is made to work on any lock-like object, while <code>condition_variable</code> is designed specifically to work with <code>unique_lock&lt;mutex&gt;</code>. The latter is probably easier to implement and/or more performant than the former, since it knows specifically which types it is operating on and what they require (whether they're trivial, whether they fit in a cache line, whether they map directly to a specific platform's set of syscalls, what fences or cache coherence guarantees they imply, etc.), while the former provides a generic facility for operating on lock-ish objects without being stuck specifically with the constraints of <code>std::mutex</code> or <code>std::unique_lock&lt;&gt;</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload