[cfe-dev] [libc++] Porting libc++ to Windows

David Chisnall David.Chisnall at cl.cam.ac.uk
Thu Jul 2 02:44:31 PDT 2015


On 2 Jul 2015, at 10:33, Kim Gräsman <kim.grasman at gmail.com> wrote:
> 
> Windows also has a light-weight mutex concept they call critical
> sections, it's been around since forever. That's what std::mutex
> should map to, not the Windows Mutex.

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:

 - Specify a timeout after which they’ll stop blocking (maybe you can do this by combining TryEnterCriticalSection and WaitForSingleObject?)

 - Be atomically released when waiting on a condition variable and reacquired

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.

David





More information about the cfe-dev mailing list