Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86010 - branches/release/boost/thread
From: vicente.botet_at_[hidden]
Date: 2013-09-29 15:10:11


Author: viboes
Date: 2013-09-29 15:10:11 EDT (Sun, 29 Sep 2013)
New Revision: 86010
URL: http://svn.boost.org/trac/boost/changeset/86010

Log:
Thread: ensure that the thread is joined on the future destructor created by future<T>::then().

Text files modified:
   branches/release/boost/thread/future.hpp | 18 +++++++++++++++---
   1 files changed, 15 insertions(+), 3 deletions(-)

Modified: branches/release/boost/thread/future.hpp
==============================================================================
--- branches/release/boost/thread/future.hpp Sun Sep 29 14:44:35 2013 (r86009)
+++ branches/release/boost/thread/future.hpp 2013-09-29 15:10:11 EDT (Sun, 29 Sep 2013) (r86010)
@@ -821,8 +821,12 @@
         struct future_async_shared_state_base: shared_state<Rp>
         {
           typedef shared_state<Rp> base_type;
+ protected:
           boost::thread thr_;
-
+ void join()
+ {
+ if (thr_.joinable()) thr_.join();
+ }
         public:
           future_async_shared_state_base()
           {
@@ -836,12 +840,12 @@
 
           ~future_async_shared_state_base()
           {
- if (thr_.joinable()) thr_.join();
+ join();
           }
 
           virtual void wait(bool rethrow)
           {
- if (thr_.joinable()) thr_.join();
+ join();
               this->base_type::wait(rethrow);
           }
         };
@@ -3769,6 +3773,10 @@
           that->mark_exceptional_finish();
         }
       }
+ ~future_async_continuation_shared_state()
+ {
+ this->join();
+ }
     };
 
     template<typename F, typename Fp>
@@ -3810,6 +3818,10 @@
           that->mark_exceptional_finish();
         }
       }
+ ~future_async_continuation_shared_state()
+ {
+ this->join();
+ }
     };
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk