Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In general mutexes can be used to control thread access across processes via a named mutex while critical sections are only for synchronizing thread access in the same process space.</p> <p>Neither of these classes truly get the benefit of RAII without wrapping them because in that case you would never need to explicitly call lock or unlock. Take for example this little bit of pseudo code using a boost mutex lock ...</p> <pre><code>void DoSomething() { // construction acquires lock on mutex boost::scoped_lock lock(&amp;aBoostMutex); // ... } // end scope - object is destroyed and lock is released </code></pre> <p>Now I'd argue you should avoid <code>CMutex</code>, <code>CCritalSection</code>, <code>CSemaphore</code>, and <code>CEvent</code> because the implementations are somewhat broken or at the very least inferior to other available libraries like boost. For example:</p> <ul> <li>Determining between a timeout from an abandoned mutex is impossible because the implementation checks return value only not the reason.</li> <li>No reentrant locks using <code>CSingleLock</code> so recursion will cause issues.</li> <li>Inability to have a named event between processes</li> </ul> <p>Depending on what you are tasked with you might have the opportunity to move away from the MFC wrappers on windows API and either implement your own atomic locks or use something like boost or C++0x features like <code>std::mutex</code> which not only are better implementations but provide cross-platform support.</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. 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