diff options
author | Howard Hinnant <hhinnant@apple.com> | 2010-08-27 20:10:19 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2010-08-27 20:10:19 +0000 |
commit | 167fd1084bcb59dc26d3d3e9b993723800c478b9 (patch) | |
tree | 86321cc0089272615b6826ed3c3cc499206e283f /libcxx/src/thread.cpp | |
parent | 212a492063944c97b20e009100c67c946644194c (diff) | |
download | bcm5719-llvm-167fd1084bcb59dc26d3d3e9b993723800c478b9.tar.gz bcm5719-llvm-167fd1084bcb59dc26d3d3e9b993723800c478b9.zip |
future continues ...
llvm-svn: 112284
Diffstat (limited to 'libcxx/src/thread.cpp')
-rw-r--r-- | libcxx/src/thread.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp index 992976500e5..f8407067270 100644 --- a/libcxx/src/thread.cpp +++ b/libcxx/src/thread.cpp @@ -9,6 +9,8 @@ #include "thread" #include "exception" +#include "vector" +#include "future" #include <sys/types.h> #include <sys/sysctl.h> @@ -81,4 +83,57 @@ sleep_for(const chrono::nanoseconds& ns) } // this_thread +__thread_specific_ptr<__thread_struct> __thread_local_data; + +// __thread_struct_imp + +class __thread_struct_imp +{ + typedef vector<__assoc_sub_state*> _AsyncStates; + _AsyncStates async_states_; + + __thread_struct_imp(const __thread_struct_imp&); + __thread_struct_imp& operator=(const __thread_struct_imp&); +public: + __thread_struct_imp() {} + ~__thread_struct_imp(); + + void __make_ready_at_thread_exit(__assoc_sub_state* __s); +}; + +__thread_struct_imp::~__thread_struct_imp() +{ + for (_AsyncStates::iterator i = async_states_.begin(), e = async_states_.end(); + i != e; ++i) + { + (*i)->__make_ready(); + (*i)->__release_shared(); + } +} + +void +__thread_struct_imp::__make_ready_at_thread_exit(__assoc_sub_state* __s) +{ + async_states_.push_back(__s); + __s->__add_shared(); +} + +// __thread_struct + +__thread_struct::__thread_struct() + : __p_(new __thread_struct_imp) +{ +} + +__thread_struct::~__thread_struct() +{ + delete __p_; +} + +void +__thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s) +{ + __p_->__make_ready_at_thread_exit(__s); +} + _LIBCPP_END_NAMESPACE_STD |