Construct client return values in place #32

issue ryanofsky opened this issue on March 20, 2020
  1. ryanofsky commented at 3:51 PM on March 20, 2020: collaborator

    Currently IPC method return types have to be default constructible, and can be copied or moved unnecessarily when ReadField is called. It would be better to construct return values in place to stop requiring default constructors, simplify code generation, and stop creating temporary copies unnecessarily.

    Way to do this would be to change clientInvoke function to return an actual value instead of void, so generated client method code would change from:

    typename M1::Result result;
    clientInvoke(..., MakeClientParam(result));
    return result;
    

    to:

    return clientInvoke(..., MakeClientReturn<M1::Result>());
    

    This should work with the existing CustomReadField functions but ReadField will have to be updated to not return void:

    template <typename... LocalTypes, typename... Args>
    decltype(auto) ReadField(TypeList<LocalTypes...>, Args&&... args)
    {
        return CustomReadField(TypeList<RemoveCvRef<LocalTypes>...>(), std::forward<Args>(args)...);
    }
    

    And a new ReadDest helper type will be required to pass into ReadField:

    template<typename Type>
    struct ReadDestReturn
    {
        template <typename... Args>
        auto& construct(Args&&... args)
        {
            return Type(std::forward<Args>(args)...);
        }
    
        template <typename UpdateFn>
        Type update(UpdateFn&& update_fn)
        {
            Type ret;
            update_fn(ret);
            return ret;
        }
    };
    
  2. ryanofsky referenced this in commit 85df929b4e on Jul 10, 2025
  3. ryanofsky referenced this in commit 30431bc0c6 on Jul 10, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-18 13:30 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me