Index: future.hpp =================================================================== --- future.hpp (revision 75884) +++ future.hpp (working copy) @@ -6,6 +6,7 @@ #ifndef BOOST_THREAD_FUTURE_HPP #define BOOST_THREAD_FUTURE_HPP + #include #include #include @@ -93,6 +94,7 @@ { boost::exception_ptr exception; bool done; + bool thread_was_interrupted; boost::mutex mutex; boost::condition_variable waiters; typedef std::list waiter_list; @@ -100,7 +102,8 @@ boost::function callback; future_object_base(): - done(false) + done(false), + thread_was_interrupted(false) {} virtual ~future_object_base() {} @@ -165,6 +168,10 @@ { waiters.wait(lock); } + if(rethrow && thread_was_interrupted) + { + throw boost::thread_interrupted(); + } if(rethrow && exception) { boost::rethrow_exception(exception); @@ -196,16 +203,22 @@ boost::lock_guard lock(mutex); mark_exceptional_finish_internal(boost::current_exception()); } + void mark_interrupted_finish() + { + boost::lock_guard lock(mutex); + thread_was_interrupted=true; + mark_finished_internal(); + } bool has_value() { boost::lock_guard lock(mutex); - return done && !exception; + return done && !(exception || thread_was_interrupted); } bool has_exception() { boost::lock_guard lock(mutex); - return done && exception; + return done && (exception || thread_was_interrupted); } template @@ -1230,6 +1243,10 @@ { this->mark_finished_with_result(f()); } + catch(thread_interrupted& it) + { + this->mark_interrupted_finish(); + } catch(...) { this->mark_exceptional_finish(); @@ -1256,6 +1273,10 @@ f(); this->mark_finished_with_result(); } + catch(thread_interrupted& it) + { + this->mark_interrupted_finish(); + } catch(...) { this->mark_exceptional_finish();