Skip to content

Conversation

tongke6
Copy link
Member

@tongke6 tongke6 commented Sep 22, 2025

No description provided.

@tongke6 tongke6 requested review from a team, FollyCoolly, danqi437 and rivertalk September 22, 2025 08:54
Copy link

Summary of Changes

Hello @tongke6, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the link::IChannel interface by modifying its asynchronous send methods to accept Buffer objects by value. This change simplifies the method signatures across the interface and its various implementations, including Channel, ChannelMem, and MockChannel, while maintaining efficient move semantics where applicable. The refactoring aims to improve code clarity and consistency in how Buffer objects are handled during asynchronous message sending.

Highlights

  • Interface Refactoring: The IChannel interface's SendAsync and SendAsyncThrottled methods now accept Buffer objects by value instead of by rvalue reference (Buffer&&).
  • Implementation Alignment: All concrete implementations (Channel, ChannelMem) and mock implementations (MockChannel) have been updated to match the new interface signature, accepting Buffer by value.
  • Move Semantics Preservation: Overloads accepting ByteContainerView now explicitly use std::move when converting to Buffer and passing to the by-value methods, ensuring efficient resource transfer is maintained.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the link::IChannel interface to use pass-by-value for Buffer sink parameters instead of r-value references. This is a positive change that aligns with modern C++ best practices, making the API more flexible by allowing both l-values (via copy) and r-values (via move) to be passed. The changes have been applied consistently across the interface, mock objects, and concrete implementations. My review includes a couple of suggestions to remove redundant std::move calls on temporary objects, which will improve code clarity and adherence to idiomatic C++.

tongke6 and others added 2 commits September 22, 2025 16:58
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
}

virtual void SendAsync(const std::string& key, Buffer&& value) = 0;
virtual void SendAsync(const std::string& key, Buffer value) = 0;
Copy link

@FollyCoolly FollyCoolly Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

移除 rvalue interface 的原因是 pybind 不支持移动语义吗?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

支持得不太好。另外,在接口里暴露 rr value 也不是好的设计。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在 ByteContainerView 为参数的 SendAsync 是通过调用 Buffer&& 为参数的 SendAsync 实现的。
而 Buffer 的拷贝是深拷贝(作为RAII Object,也确实需要是深拷贝)。
似乎有效率问题

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image gemini 有不同的意见...相信 gemini

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

很好的问题,我最开始在里面调用的时候,显示第手写了 std::move,但是 gemini 还是 copolit 提醒我是不必要的,编译器会自动给临时对象添加 std::move,避免拷贝。

这个问题可以写个 demo 快速地验证下。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

很好的问题,我最开始在里面调用的时候,显示第手写了 std::move,但是 gemini 还是 copolit 提醒我是不必要的,编译器会自动给临时对象添加 std::move,避免拷贝。

这个问题可以写个 demo 快速地验证下。

验过了,gemini是对的

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

写了一个 example,如 gemin 所说,直接构造了 Buffer 参数,都没有调用 移动构造函数和拷贝构造函数。https://godbolt.org/z/EK5EKvjqa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants