[PATCH] D28220: provide Win32 native threading

David Majnemer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 2 18:32:28 PST 2017


majnemer added inline comments.


================
Comment at: include/__threading_support:300-305
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+{
+  InitializeSRWLock(__m);
+  return 0;
+}
+
----------------
I don't think you can use slim rw locks for recursive locks. I think we will need to use `CRITICAL_SECTION` for those. std::recursive_mutex can't be used with std::condition_variable AFAIK so all you need (I think) is recursive versions of `__libcpp_mutex_...`

Recursive locks should be used far less frequently which makes it valuable, IMO, to use slim rw locks for the non-recursive mutex implementation.


================
Comment at: include/__threading_support:355
+  // TODO(compnerd) handle spurious timeout
+  if (!SleepConditionVariableSRW(__cv, __m,
+                                 duration_cast<milliseconds>(timeout).count(),
----------------
I don't think it should be `__libcpp_condvar_timedwait'`s problem. `__libcpp_condvar_timedwait` wraps `pthread_cond_timedwait` on POSIX platforms and the caller of `__libcpp_condvar_wait` properly handles spurious wakeups. The caller of `__libcpp_condvar_timedwait` probably should be audited.


Repository:
  rL LLVM

https://reviews.llvm.org/D28220





More information about the cfe-commits mailing list