Re: [Boost-bugs] [Boost C++ Libraries] #11818: future.then will be blocked if promise is set after the invocation of then

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11818: future.then will be blocked if promise is set after the invocation of then
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-11-24 17:28:47


#11818: future.then will be blocked if promise is set after the invocation of then
---------------------------------------------+----------------------
  Reporter: Xiaoshuang LU <luxiaoshuang@…> | Owner: viboes
      Type: Bugs | Status: assigned
 Milestone: To Be Determined | Component: thread
   Version: Boost 1.59.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------------------+----------------------
Changes (by viboes):

 * owner: anthonyw => viboes
 * status: new => assigned


Old description:

> int function()
> {
> boost::promise<int> promise;
> boost::future<int> future = promise.get_future();
>
> boost::future<int> result =
> future.then
> (
> boost::launch::deferred,
> [](boost::future<int> && f)
> {
> std::cout << std::this_thread::get_id() << ": callback" <<
> std::endl;
> std::cout << "The value is: " << f.get() << std::endl;
> return f.get();
> }
> );
>
> // We could not reach here.
> std::cout << std::this_thread::get_id() << ": function" << std::endl;
>
> promise.set_value(0);
>
> return 0;
> }

New description:

 {{{
 int function()
 {
     boost::promise<int> promise;
     boost::future<int> future = promise.get_future();

     boost::future<int> result =
     future.then
     (
         boost::launch::deferred,
         [](boost::future<int> && f)
         {
             std::cout << std::this_thread::get_id() << ": callback" <<
 std::endl;
             std::cout << "The value is: " << f.get() << std::endl;
             return f.get();
         }
     );

     // We could not reach here.
     std::cout << std::this_thread::get_id() << ": function" << std::endl;

     promise.set_value(0);

     return 0;
 }
 }}}

--
-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11818#comment:2>
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-02-16 18:50:19 UTC