Ticket #5351: 5351.diff
File 5351.diff, 2.9 KB (added by , 11 years ago) |
---|
-
future.hpp
6 6 7 7 #ifndef BOOST_THREAD_FUTURE_HPP 8 8 #define BOOST_THREAD_FUTURE_HPP 9 9 10 #include <stdexcept> 10 11 #include <boost/thread/detail/move.hpp> 11 12 #include <boost/thread/thread_time.hpp> … … 93 94 { 94 95 boost::exception_ptr exception; 95 96 bool done; 97 bool thread_was_interrupted; 96 98 boost::mutex mutex; 97 99 boost::condition_variable waiters; 98 100 typedef std::list<boost::condition_variable_any*> waiter_list; … … 100 102 boost::function<void()> callback; 101 103 102 104 future_object_base(): 103 done(false) 105 done(false), 106 thread_was_interrupted(false) 104 107 {} 105 108 virtual ~future_object_base() 106 109 {} … … 165 168 { 166 169 waiters.wait(lock); 167 170 } 171 if(rethrow && thread_was_interrupted) 172 { 173 throw boost::thread_interrupted(); 174 } 168 175 if(rethrow && exception) 169 176 { 170 177 boost::rethrow_exception(exception); … … 196 203 boost::lock_guard<boost::mutex> lock(mutex); 197 204 mark_exceptional_finish_internal(boost::current_exception()); 198 205 } 206 void mark_interrupted_finish() 207 { 208 boost::lock_guard<boost::mutex> lock(mutex); 209 thread_was_interrupted=true; 210 mark_finished_internal(); 199 211 212 } 200 213 bool has_value() 201 214 { 202 215 boost::lock_guard<boost::mutex> lock(mutex); 203 return done && ! exception;216 return done && !(exception || thread_was_interrupted); 204 217 } 205 218 bool has_exception() 206 219 { 207 220 boost::lock_guard<boost::mutex> lock(mutex); 208 return done && exception;221 return done && (exception || thread_was_interrupted); 209 222 } 210 223 211 224 template<typename F,typename U> … … 1230 1243 { 1231 1244 this->mark_finished_with_result(f()); 1232 1245 } 1246 catch(thread_interrupted& it) 1247 { 1248 this->mark_interrupted_finish(); 1249 } 1233 1250 catch(...) 1234 1251 { 1235 1252 this->mark_exceptional_finish(); … … 1256 1273 f(); 1257 1274 this->mark_finished_with_result(); 1258 1275 } 1276 catch(thread_interrupted& it) 1277 { 1278 this->mark_interrupted_finish(); 1279 } 1259 1280 catch(...) 1260 1281 { 1261 1282 this->mark_exceptional_finish();