Re: [Boost-bugs] [Boost C++ Libraries] #10964: future<future<T>>::unwrap().then() Deadlocks

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10964: future<future<T>>::unwrap().then() Deadlocks
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-07-06 06:46:05


#10964: future<future<T>>::unwrap().then() Deadlocks
-------------------------------+---------------------
  Reporter: code@… | Owner: viboes
      Type: Bugs | Status: closed
 Milestone: To Be Determined | Component: thread
   Version: Boost 1.57.0 | Severity: Problem
Resolution: fixed | Keywords:
-------------------------------+---------------------

Comment (by Mattéo Delabre ✏ <contact@…>):

 I’ve encountered a similar problem while using deferred continuations (see
 https://stackoverflow.com/questions/44748568/boostfuture-deferred-
 continuation-unwrapping-deadlocks).

 {{{
 #define BOOST_THREAD_VERSION 5

 #include <iostream>
 #include <boost/thread/future.hpp>

 int main(int argc, char* argv[])
 {
     boost::promise<int> promise;
     boost::future<int> future = promise.get_future();

     promise.set_value(42);

     int result = future.then(
         boost::launch::deferred,
         [](boost::future<int> result)
         {
             return boost::make_ready_future(result.get());
         }
     ).unwrap().get();

     std::cout << "Result is: " << result << std::endl;
     return 0;
 }
 }}}

 This code causes a deadlock. If the launch policy is replaced by
 `boost::launch::async`, it works as intended.

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/10964#comment:16>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-07-06 06:49:37 UTC