<p dir="ltr">Hi David,</p>
<p dir="ltr">Right you are, I didn't know std::mutex had timed waits. Sorry for the disinfo.</p>
<p dir="ltr">- Kim</p>
<div class="gmail_quote">Den 2 jul 2015 11:44 skrev "David Chisnall" <<a href="mailto:David.Chisnall@cl.cam.ac.uk">David.Chisnall@cl.cam.ac.uk</a>>:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2 Jul 2015, at 10:33, Kim Gräsman <<a href="mailto:kim.grasman@gmail.com">kim.grasman@gmail.com</a>> wrote:<br>
><br>
> Windows also has a light-weight mutex concept they call critical<br>
> sections, it's been around since forever. That's what std::mutex<br>
> should map to, not the Windows Mutex.<br>
<br>
Unless I’m missing something (and I may well be - last time I wrote any Win32 code, NT 5 was in beta), CriticalSection objects can not:<br>
<br>
 - Specify a timeout after which they’ll stop blocking (maybe you can do this by combining TryEnterCriticalSection and WaitForSingleObject?)<br>
<br>
 - Be atomically released when waiting on a condition variable and reacquired<br>
<br>
Both of these are required for std::mutex.  SRWLocks support the second, though don’t seem to provide a clean way of implementing the first.<br>
<br>
David<br>
<br>
</blockquote></div>