libs/core/futures/src/future_data.cpp
void future_data_base<traits::detail::future_data_void>::set_on_completed(
        completed_callback_type data_sink)
    {
        if (!data_sink)
            return;

        if (is_ready())
        {
            // invoke the callback (continuation) function right away
            handle_on_completed(std::move(data_sink));
        }
        else
        {
            std::unique_lock<mutex_type> l(mtx_);
            if (is_ready())
            {
                l.unlock();

                // invoke the callback (continuation) function
                handle_on_completed(std::move(data_sink));
            }
            else
            {
                on_completed_.push_back(std::move(data_sink));
            }
        }
    }
/// Set the callback which needs to be invoked when the future becomes
/// ready. If the future is ready the function will be invoked
/// immediately.
Set the callback which needs to be invoked when the future becomes
ready. If the future is ready the function will be invoked
immediately.
Set the callback which needs to be invoked when the future becomes ready . If the future is ready the function will be invoked immediately .
void future_data_base<traits::detail::future_data_void>::set_on_completed(
        completed_callback_type data_sink)
    {
        if (!data_sink)
            return;
        if (is_ready())
        {
            handle_on_completed(std::move(data_sink));
        }
        else
        {
            std::unique_lock<mutex_type> l(mtx_);
            if (is_ready())
            {
                l.unlock();
                handle_on_completed(std::move(data_sink));
            }
            else
            {
                on_completed_.push_back(std::move(data_sink));
            }
        }
    }
void future_data_base < traits :: detail :: future_data_void > :: set_on_completed ( completed_callback_type data_sink ) { if ( ! data_sink ) return ; if ( is_ready ( ) ) { handle_on_completed ( std :: move ( data_sink ) ) ; } else { std :: unique_lock < mutex_type > l ( mtx_ ) ; if ( is_ready ( ) ) { l . unlock ( ) ; handle_on_completed ( std :: move ( data_sink ) ) ; } else { on_completed_ . push_back ( std :: move ( data_sink ) ) ; } } }
Set the callback which needs to be invoked when the future becomes
ready.
Set the callback which needs to be invoked when the future becomes ready .
// invoke the callback (continuation) function right away // invoke the callback (continuation) function