Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#11231 closed Feature Requests (fixed)

Allow to set continuation future's destructor behavior to non-blocking

Reported by: Konrad Zemek <konrad.zemek@…> Owned by: viboes
Milestone: Boost 1.60.0 Component: thread
Version: Boost 1.58.0 Severity: Not Applicable
Keywords: Cc:

Description

As discussed on the mailing list:

Currently, continuation futures created using future<>::then() with boost::launch::async or an executor block on destruction (until the value is ready).

I would like there to be a way to disable this behavior, whether through an additional argument in future<>::then() (much like boost::defer_lock in locks' constructors), a method explicitly setting the non-blocking behavior, or implicitly through a call to future<>::wait_for/until().

Change History (5)

comment:1 by viboes, 7 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:3 by viboes, 7 years ago

Resolution: fixed
Status: assignedclosed

4321b59c1eedde71da58f592aa4c741a1feff046

comment:4 by anonymous, 7 years ago

The blocking option seems to be broken. Future destructor doesn't block even if BOOST_THREAD_FUTURE_BLOCKING is defined and the futture was obtained by a call to boost::async() with boost::launch::async, or by calling other_future.then().

int main()
{
    {
        auto future = boost::async(boost::launch::async, []() {
            std::this_thread::sleep_for(1s);
            return 42;
        });
    } //future destructor doesn't block

    //do stuff...
    //-> will heppen before the future state is ready
}

in reply to:  4 comment:5 by anonymous, 6 years ago

Replying to anonymous:

The blocking option seems to be broken. Future destructor doesn't block even if BOOST_THREAD_FUTURE_BLOCKING is defined and the futture was obtained by a call to boost::async() with boost::launch::async, or by calling other_future.then().

int main()
{
    {
        auto future = boost::async(boost::launch::async, []() {
            std::this_thread::sleep_for(1s);
            return 42;
        });
    } //future destructor doesn't block

    //do stuff...
    //-> will heppen before the future state is ready
}

The future destructor is never called even though the variable 'future' goes out of scope. See ticket #12220 for details.

Note: See TracTickets for help on using tickets.