add async_uring_cmd#4
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for two new async io_uring operations: async_uring_cmd (a generic uring command operation) and async_cmd_getsockname (to get socket name information). Both operations support fixed file descriptors and are conditionally compiled for io_uring version 2.13 and later.
Key changes:
- Adds
async_uring_cmdas a flexible template function that allows custom command operations with user-provided callback - Adds
async_cmd_getsocknamewrapper for the io_uring getsockname command - Includes comprehensive test coverage for both operations with regular and fixed file descriptors
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| include/condy/async_operations.hpp | Implements async_uring_cmd and async_cmd_getsockname functions with appropriate version guards and fixed fd support |
| tests/test_async_operations.cpp | Adds four test cases covering basic and fixed fd scenarios for both new operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0638d4a to
07fc28a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| inline auto async_uring_cmd(int cmd_op, Fd fd, CmdFunc &&cmd_func) { | ||
| auto prep_func = [cmd_func = std::forward<CmdFunc>(cmd_func)]( | ||
| io_uring_sqe *sqe, int cmd_op_inner, int fd_inner) { | ||
| io_uring_prep_uring_cmd(sqe, cmd_op_inner, fd_inner); | ||
| cmd_func(sqe); | ||
| }; | ||
| auto op = make_op_awaiter(std::move(prep_func), cmd_op, fd); | ||
| return detail::maybe_flag_fixed_fd(std::move(op), fd); |
There was a problem hiding this comment.
async_uring_cmd routes the user-supplied cmd_func through make_op_awaiter, which ultimately calls it from a const lambda. This implicitly requires cmd_func to be const-invocable; passing a callable with a non-const operator() (e.g., a mutable lambda) will fail to compile. Consider constructing the final SQE-prep lambda directly (capturing cmd_op, fd, and a decayed cmd_func) so the callback can be invoked without the extra wrapper and without the const-invocable restriction.
|
New version #42 |
for linux 6.19