[futures.atomic_future] and notify_all_at_thread_exit. This completes the header <future> and all of Chapter 30 (for C++0x enabled compilers).
llvm-svn: 113017
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: b77c0c03bb5f48c7ff98aa0d8dd5c648e8a1a651
diff --git a/src/thread.cpp b/src/thread.cpp
index f840706..3d388e9 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -90,7 +90,10 @@
class __thread_struct_imp
{
typedef vector<__assoc_sub_state*> _AsyncStates;
+ typedef vector<pair<condition_variable*, mutex*> > _Notify;
+
_AsyncStates async_states_;
+ _Notify notify_;
__thread_struct_imp(const __thread_struct_imp&);
__thread_struct_imp& operator=(const __thread_struct_imp&);
@@ -98,11 +101,18 @@
__thread_struct_imp() {}
~__thread_struct_imp();
+ void notify_all_at_thread_exit(condition_variable* cv, mutex* m);
void __make_ready_at_thread_exit(__assoc_sub_state* __s);
};
__thread_struct_imp::~__thread_struct_imp()
{
+ for (_Notify::iterator i = notify_.begin(), e = notify_.end();
+ i != e; ++i)
+ {
+ i->second->unlock();
+ i->first->notify_all();
+ }
for (_AsyncStates::iterator i = async_states_.begin(), e = async_states_.end();
i != e; ++i)
{
@@ -112,6 +122,12 @@
}
void
+__thread_struct_imp::notify_all_at_thread_exit(condition_variable* cv, mutex* m)
+{
+ notify_.push_back(pair<condition_variable*, mutex*>(cv, m));
+}
+
+void
__thread_struct_imp::__make_ready_at_thread_exit(__assoc_sub_state* __s)
{
async_states_.push_back(__s);
@@ -131,6 +147,12 @@
}
void
+__thread_struct::notify_all_at_thread_exit(condition_variable* cv, mutex* m)
+{
+ __p_->notify_all_at_thread_exit(cv, m);
+}
+
+void
__thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s)
{
__p_->__make_ready_at_thread_exit(__s);