https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69724

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>:

https://gcc.gnu.org/g:bb1b7f087bdd028000fd8f84e74b20adccc9d5bb

commit r11-2736-gbb1b7f087bdd028000fd8f84e74b20adccc9d5bb
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Aug 18 14:23:19 2020 +0100

    libstdc++: Remove redundant copying of std::async arguments [PR 69724]

    As was previously done for std::thread, this removes an unnecessary copy
    of an rvalue of type thread::_Invoker. Instead of creating the rvalue
    and then moving that into the shared state, the member of the shared
    state is initialized directly from the forwarded callable and bound
    arguments.

    This also slightly simplifies std::thread creation to remove the
    _S_make_state helper function.

    libstdc++-v3/ChangeLog:

            PR libstdc++/69724
            * include/std/future (__future_base::_S_make_deferred_state)
            (__future_base::_S_make_async_state): Remove.
            (__future_base::_Deferred_state): Change constructor to accept a
            parameter pack of arguments and forward them to the call
            wrapper.
            (__future_base::_Async_state_impl): Likewise. Replace lambda
            expression with a named member function.
            (async): Construct state object directly from the arguments,
            instead of using thread::__make_invoker, _S_make_deferred_state
            and _S_make_async_state. Move shared state into the returned
            future.
            * include/std/thread (thread::_Call_wrapper): New alias
            template for use by constructor and std::async.
            (thread::thread(Callable&&, Args&&...)): Create state object
            directly instead of using _S_make_state.
            (thread::__make_invoker, thread::__decayed_tuple)
            (thread::_S_make_state): Remove.
            * testsuite/30_threads/async/69724.cc: New test.

Reply via email to