Commit Graph

6 Commits

Author SHA1 Message Date
Marshall Clow
abadb458d0 Implement N4508: shared_mutex. Reviewed as http://reviews.llvm.org/D10480
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@241067 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-30 14:04:14 +00:00
Eric Fiselier
1d55ecf513 [libcxx] Fix bug in shared_timed_mutex that could cause a program to hang.
Summary:
The summary of the bug, provided by Stephan T. Lavavej:

In shared_timed_mutex::try_lock_until() (line 195 in 3.6.0), you need to deliver a notification.  The scenario is:
 
* There are N threads holding the shared lock.
* One thread calls try_lock_until() to attempt to acquire the exclusive lock.  It sets the "I want to write" bool/bit, then waits for the N readers to drain away.
* K more threads attempt to acquire the shared lock, but they notice that someone said "I want to write", so they block on a condition_variable.
* At least one of the N readers is stubborn and doesn't release the shared lock.
* The wannabe-writer times out, gives up, and unsets the "I want to write" bool/bit.
 
At this point, a notification (it needs to be notify_all) must be delivered to the condition_variable that the K wannabe-readers are waiting on.  Otherwise, they can block forever without waking up.



Reviewers: mclow.lists, jyasskin

Reviewed By: jyasskin

Subscribers: jyasskin, cfe-commits

Differential Revision: http://reviews.llvm.org/D8796

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@233944 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-02 21:02:06 +00:00
Jonathan Roelofs
8d86b2e686 Allow libc++ to be built on systems without POSIX threads
If you're crazy enough to want this sort of thing, then add
-D_LIBCPP_HAS_NO_THREADS to your CXXFLAGS and
--param=additiona_features=libcpp-has-no-threads to your lit commnad line.

http://reviews.llvm.org/D3969


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@217271 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-05 19:45:05 +00:00
Marshall Clow
861f1e95fd Replace 'noexcept' with '_NOEXCEPT' in <shared_mutex>. This allows us to build the dylib with MSVC, which doesn't support noexcept (sheesh\!). Thanks to K-ballo for the report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@216384 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 14:53:16 +00:00
David Majnemer
f9f95be930 Implement N3891: A proposal to rename shared_mutex to shared_timed_mutex
This is as straightforward as it sounds, a renamed from shared_mutex to
shared_timed_mutex.

Note that libcxx .dylib and .so files built with c++14 support need to
be rebuilt.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@204078 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-17 20:19:44 +00:00
Howard Hinnant
ba898e4208 N3659: Shared locking in C++ Revision 2, c++1y only
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@191127 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-21 01:49:28 +00:00