Opened 7 years ago

Last modified 7 years ago

#11818 closed Bugs

future.then will be blocked if promise is set after the invocation of then — at Version 2

Reported by: Xiaoshuang LU <luxiaoshuang@…> Owned by: viboes
Milestone: Boost 1.60.0 Component: thread
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description (last modified by viboes)

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;
}

Change History (2)

comment:1 by Xiaoshuang LU <luxiaoshuang@…>, 7 years ago

Summary: future.then will be blocked if promise is set after then invocation of thenfuture.then will be blocked if promise is set after the invocation of then

comment:2 by viboes, 7 years ago

Description: modified (diff)
Owner: changed from Anthony Williams to viboes
Status: newassigned
Note: See TracTickets for help on using tickets.