[PATCH] [libcxx] Fix bug in shared_timed_mutex that could cause a program to hang.

Jeffrey Yasskin jyasskin at gmail.com
Thu Apr 2 13:43:33 PDT 2015


In http://reviews.llvm.org/D8796#151237, @EricWF wrote:

> > The fix itself looks correct to me.
>
>
> Good! The fix I had before released the mutex before calling notify_all(). I was hoping to do that as an optimization but I don't think it is possible. Should I be at all concerned about notifying other threads while holding the lock?


There's no requirement that the mutex be either locked or unlocked when you call notify_*(). One choice might be faster than the other, but it depends on the mutex+condvar implementation. (A smart mutex+condvar can ensure that no thread is unblocked before the mutex is unlocked.) If you're tempted to optimize this, consider optimizing the fact that std::mutex uses pthread_mutex, which is big and slow, first.


http://reviews.llvm.org/D8796

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list