[cfe-commits] [libcxx] r172456 - in /libcxx/trunk: include/future src/future.cpp
Howard Hinnant
hhinnant at apple.com
Mon Jan 14 12:01:24 PST 2013
Author: hhinnant
Date: Mon Jan 14 14:01:24 2013
New Revision: 172456
URL: http://llvm.org/viewvc/llvm-project?rev=172456&view=rev
Log:
Fix a race in the construction of future. This fixes http://llvm.org/bugs/show_bug.cgi?id=14934.
Modified:
libcxx/trunk/include/future
libcxx/trunk/src/future.cpp
Modified: libcxx/trunk/include/future
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=172456&r1=172455&r2=172456&view=diff
==============================================================================
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Mon Jan 14 14:01:24 2013
@@ -470,7 +470,11 @@
{return (__state_ & __constructed) || (__exception_ != nullptr);}
_LIBCPP_INLINE_VISIBILITY
- void __set_future_attached() {__state_ |= __future_attached;}
+ void __set_future_attached()
+ {
+ lock_guard<mutex> __lk(__mut_);
+ __state_ |= __future_attached;
+ }
_LIBCPP_INLINE_VISIBILITY
bool __has_future_attached() const {return __state_ & __future_attached;}
Modified: libcxx/trunk/src/future.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/future.cpp?rev=172456&r1=172455&r2=172456&view=diff
==============================================================================
--- libcxx/trunk/src/future.cpp (original)
+++ libcxx/trunk/src/future.cpp Mon Jan 14 14:01:24 2013
@@ -78,8 +78,8 @@
throw future_error(make_error_code(future_errc::promise_already_satisfied));
#endif
__state_ |= __constructed | ready;
- __lk.unlock();
__cv_.notify_all();
+ __lk.unlock();
}
void
More information about the cfe-commits
mailing list