Ticket #7283: 7283_80241.patch
File 7283_80241.patch, 10.2 KB (added by , 10 years ago) |
---|
-
boost/thread/pthread/condition_variable_fwd.hpp
229 229 unique_lock<mutex>& lock, 230 230 struct timespec const &timeout); 231 231 }; 232 233 void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk); 232 234 } 233 235 236 234 237 #include <boost/config/abi_suffix.hpp> 235 238 236 239 #endif -
boost/thread/pthread/thread_data.hpp
8 8 9 9 #include <boost/thread/detail/config.hpp> 10 10 #include <boost/thread/exceptions.hpp> 11 #include <boost/thread/locks.hpp> 11 12 #include <boost/shared_ptr.hpp> 12 13 #include <boost/enable_shared_from_this.hpp> 13 14 #include <boost/thread/mutex.hpp> … … 117 118 typedef pthread_t native_handle_type; 118 119 119 120 virtual void run()=0; 121 virtual void notify_all_at_thread_exit(condition_variable*, mutex*)=0; 120 122 }; 121 123 122 124 BOOST_THREAD_DECL thread_data_base* get_current_thread_data(); -
boost/thread/detail/thread.hpp
23 23 #include <boost/bind.hpp> 24 24 #include <stdlib.h> 25 25 #include <memory> 26 #include <vector> 27 #include <utility> 26 28 #include <boost/utility/enable_if.hpp> 27 29 #include <boost/type_traits/remove_reference.hpp> 28 30 #include <boost/io/ios_state.hpp> … … 73 75 { 74 76 f(); 75 77 } 78 typedef std::vector<std::pair<condition_variable*, mutex*> 79 //, hidden_allocator<std::pair<condition_variable*, mutex*> > 80 > notify_list_t; 81 notify_list_t notify; 82 void notify_all_at_thread_exit(condition_variable* cv, mutex* m) 83 { 84 notify.push_back(std::pair<condition_variable*, mutex*>(cv, m)); 85 } 86 ~thread_data() 87 { 88 for (notify_list_t::iterator i = notify.begin(), e = notify.end(); 89 i != e; ++i) 90 { 91 i->second->unlock(); 92 i->first->notify_all(); 93 } 94 95 } 76 96 private: 77 97 F f; 78 98 }; … … 92 112 { 93 113 f(); 94 114 } 115 typedef std::vector<std::pair<condition_variable*, mutex*> 116 //, hidden_allocator<std::pair<condition_variable*, mutex*> > 117 > notify_list_t; 118 notify_list_t notify; 119 void notify_all_at_thread_exit(condition_variable* cv, mutex* m) 120 { 121 notify.push_back(std::pair<condition_variable*, mutex*>(cv, m)); 122 } 95 123 }; 96 124 97 125 template<typename F> … … 109 137 { 110 138 f(); 111 139 } 140 typedef std::vector<std::pair<condition_variable*, mutex*> 141 //, hidden_allocator<std::pair<condition_variable*, mutex*> > 142 > notify_list_t; 143 notify_list_t notify; 144 void notify_all_at_thread_exit(condition_variable* cv, mutex* m) 145 { 146 notify.push_back(std::pair<condition_variable*, mutex*>(cv, m)); 147 } 112 148 }; 113 149 } 114 150 -
boost/thread/win32/condition_variable.hpp
510 510 #endif 511 511 }; 512 512 513 void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk); 513 514 } 514 515 515 516 #include <boost/config/abi_suffix.hpp> -
boost/thread/win32/thread_data.hpp
11 11 #include <boost/thread/thread_time.hpp> 12 12 #include <boost/thread/win32/thread_primitives.hpp> 13 13 #include <boost/thread/win32/thread_heap_alloc.hpp> 14 #include <boost/thread/win32/condition_variable.hpp> 15 #include <boost/thread/locks.hpp> 14 16 #include <map> 15 17 #ifdef BOOST_THREAD_USES_CHRONO 16 18 #include <boost/chrono/system_clocks.hpp> … … 117 119 typedef detail::win32::handle native_handle_type; 118 120 119 121 virtual void run()=0; 122 virtual void notify_all_at_thread_exit(condition_variable*, mutex*)=0; 123 120 124 }; 121 125 122 126 typedef boost::intrusive_ptr<detail::thread_data_base> thread_data_ptr; -
libs/thread/test/threads/thread/members/detach_pass.cpp
17 17 18 18 // void detach(); 19 19 20 #define BOOST_THREAD_VESRION 3 21 20 22 #include <boost/thread/thread.hpp> 21 23 #include <new> 22 24 #include <cstdlib> -
libs/thread/test/sync/conditions/notify_all_at_thread_exit_pass.cpp
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // Copyright (C) 2011 Vicente J. Botet Escriba 10 // 11 // Distributed under the Boost Software License, Version 1.0. (See accompanying 12 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 13 14 // <boost/thread/condition_variable.hpp> 15 16 // void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk); 17 18 #define BOOST_THREAD_USES_MOVE 19 #define BOOST_THREAD_VESRION 3 20 21 #include <boost/thread/condition_variable.hpp> 22 #include <boost/thread/mutex.hpp> 23 #include <boost/thread/locks.hpp> 24 #include <boost/thread/thread.hpp> 25 #include <boost/chrono/chrono.hpp> 26 #include <boost/detail/lightweight_test.hpp> 27 28 boost::condition_variable cv; 29 boost::mutex mut; 30 31 typedef boost::chrono::milliseconds ms; 32 typedef boost::chrono::high_resolution_clock Clock; 33 34 void func() 35 { 36 boost::unique_lock < boost::mutex > lk(mut); 37 boost::notify_all_at_thread_exit(cv, boost::move(lk)); 38 boost::this_thread::sleep_for(ms(300)); 39 } 40 41 int main() 42 { 43 boost::unique_lock < boost::mutex > lk(mut); 44 boost::thread(func).detach(); 45 Clock::time_point t0 = Clock::now(); 46 cv.wait(lk); 47 Clock::time_point t1 = Clock::now(); 48 BOOST_TEST(t1 - t0 > ms(250)); 49 return boost::report_errors(); 50 } 51 -
libs/thread/test/Jamfile.v2
Property changes on: libs/thread/test/sync/conditions/notify_all_at_thread_exit_pass.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id Added: svn:eol-style + native
225 225 [ thread-run2 ./sync/conditions/condition_variable_any/wait_until_pass.cpp : condition_variable_any__wait_until_p ] 226 226 [ thread-run2 ./sync/conditions/condition_variable_any/wait_until_pred_pass.cpp : condition_variable_any__wait_until_pred_p ] 227 227 [ thread-run2 ./sync/conditions/cv_status/cv_status_pass.cpp : cv_status__cv_status_p ] 228 [ thread-run2 ./sync/conditions/notify_all_at_thread_exit_pass.cpp : notify_all_at_thread_exit_p ] 228 229 ; 229 230 230 231 explicit ts_async ; -
libs/thread/src/win32/thread.cpp
20 20 #include <stdio.h> 21 21 #include <boost/thread/once.hpp> 22 22 #include <boost/thread/tss.hpp> 23 #include <boost/thread/condition_variable.hpp> 23 24 #include <boost/assert.hpp> 24 25 #include <boost/throw_exception.hpp> 25 26 #include <boost/thread/detail/tss_hooks.hpp> … … 240 241 241 242 void run() 242 243 {} 244 void notify_all_at_thread_exit(condition_variable*, mutex*) 245 {} 246 243 247 private: 244 248 externally_launched_thread(externally_launched_thread&); 245 249 void operator=(externally_launched_thread&); … … 682 686 boost::run_thread_exit_callbacks(); 683 687 } 684 688 689 void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk) 690 { 691 detail::thread_data_base* const current_thread_data(detail::get_current_thread_data()); 692 if(current_thread_data) 693 { 694 current_thread_data->notify_all_at_thread_exit(&cond, lk.release()); 695 } 696 } 685 697 } 686 698 687 699 -
libs/thread/src/pthread/thread.cpp
10 10 11 11 #include <boost/thread/thread.hpp> 12 12 #include <boost/thread/xtime.hpp> 13 #include <boost/thread/condition .hpp>13 #include <boost/thread/condition_variable.hpp> 14 14 #include <boost/thread/locks.hpp> 15 15 #include <boost/thread/once.hpp> 16 16 #include <boost/thread/tss.hpp> … … 175 175 176 176 void run() 177 177 {} 178 void notify_all_at_thread_exit(condition_variable*, mutex*) 179 {} 178 180 179 181 private: 180 182 externally_launched_thread(externally_launched_thread&); … … 677 679 } 678 680 } 679 681 } 682 void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk) 683 { 684 detail::thread_data_base* const current_thread_data(detail::get_current_thread_data()); 685 if(current_thread_data) 686 { 687 current_thread_data->notify_all_at_thread_exit(&cond, lk.release()); 688 } 689 } 680 690 681 691 692 682 693 }