-
Notifications
You must be signed in to change notification settings - Fork 38
新增跨平台异步IO模块 #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+6,302
−16
Merged
新增跨平台异步IO模块 #64
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
4e38062
新增跨平台异步IO模块
actboy168 b344d13
Update meta/async.lua
actboy168 446d656
refactor: 简化 read 逻辑并优化 buf_unpin 与 commit 调用
actboy168 6e1152e
fix: expand poll/wait return type annotation to include string for fi…
Copilot 258cf83
Update bee/async/async_uring_linux.cpp
actboy168 bb8518a
refactor: 简化异步IOURING初始化逻辑并明确内核特性要求
actboy168 a9330ff
refactor: 动态设置 io_uring_enter 的 arg 大小以提升灵活性
actboy168 185b2df
Update test/test_async.lua
actboy168 a1c82ac
refactor: 优化epoll操作前置校验与防重复提交
actboy168 41eaeb1
docs: 更新 cancel 函数注释说明为空操作及取消要求
actboy168 77f0d0e
feat: 新增 op_filter 并完善 kqueue 事件取消防 use-after-free
actboy168 023b9e3
refactor: 移除 pending_op 结构体及相关动态分配逻辑
actboy168 8b684aa
refactor: 修正环形缓冲区大小计算并兼容32/64位平台
actboy168 4b5f638
refactor: 添加异步请求资源清理与缓冲区释放
actboy168 40dace1
refactor: 重构异步事件处理,增强虚假唤醒检测与重注册可靠性
actboy168 ca52017
feat: 异步文件写入绑定buf防释放并完善错误处理
actboy168 6aab683
refactor: 引入luaref机制重构异步IO引用管理
actboy168 addbfc1
refactor: 重构异步操作机制,改用 packed_id 统一管理请求与引用
actboy168 4438893
refactor: 重构net_async读逻辑并统一常量与字段命名
actboy168 9859340
feat: 新增异步读多缓冲区支持
actboy168 aff593b
feat: 新增异步分散读支持及 read/readv 双分支处理
actboy168 06703a1
Update binding/lua_async.cpp
actboy168 f1b304d
refactor: 统一将 io_uring 相关标识及结构体前缀由 UV__ 改为 BEE__
actboy168 0d413bc
fix: 修正 io_uring_enter 重试条件并统一中断
actboy168 c17f000
feat: 新增 io_uring 超时处理及内部 timeout 类型支持
actboy168 5edf2a6
feat: 增强 Windows 异步操作支持,新增监听套接字与上下文更新
actboy168 ab6022b
Update meta/async.lua
actboy168 c6af582
refactor: 优化 submit_write 实现,新增 sqe 获取与发送逻辑
actboy168 55e23a6
feat: 新增SO_UPDATE_ACCEPT/CONNECT_CONTEXT宏并移除mstcpip/mswsock依赖
actboy168 21a3ec1
refactor: 清理并统一 Windows 异步 IO 扩展函数引用
actboy168 e5ed2fb
Update test/test_async.lua
actboy168 56958fe
fix: 修复wb_submit_all失败时资源泄漏与状态不一致问题
actboy168 29bffa4
fix: 修复 wait_completion 返回值并增加操作类型 op
actboy168 db4ab1d
refactor: 重构 wait_accept 签名并清理冗余 associate 调用
actboy168 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #include <bee/async/async.h> | ||
|
|
||
| #if defined(__linux__) | ||
| # include <bee/async/async_epoll_linux.h> | ||
| # if !defined(BEE_ASYNC_BACKEND_EPOLL) | ||
| # include <bee/async/async_uring_linux.h> | ||
| # endif | ||
| #endif | ||
|
|
||
| namespace bee::async { | ||
|
|
||
| std::unique_ptr<async> create() { | ||
| #if defined(__linux__) | ||
| # if defined(BEE_ASYNC_BACKEND_EPOLL) | ||
| return std::make_unique<async_epoll>(); | ||
| # else | ||
| auto uring = std::make_unique<async_uring>(); | ||
| if (uring->valid()) { | ||
| return uring; | ||
| } | ||
| return std::make_unique<async_epoll>(); | ||
| # endif | ||
| #else | ||
| return std::make_unique<async>(); | ||
| #endif | ||
| } | ||
|
|
||
| } // namespace bee::async |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #pragma once | ||
|
|
||
| #include <bee/async/async_types.h> | ||
| #include <bee/net/endpoint.h> | ||
| #include <bee/net/fd.h> | ||
| #include <bee/net/socket.h> | ||
| #include <bee/sys/file_handle.h> | ||
| #include <bee/utility/span.h> | ||
|
|
||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <memory> | ||
|
|
||
| #if defined(_WIN32) | ||
| # include <bee/async/async_win.h> | ||
| #elif defined(__APPLE__) | ||
| # if defined(BEE_ASYNC_BACKEND_KQUEUE) | ||
| # include <bee/async/async_bsd.h> | ||
| # else | ||
| # include <bee/async/async_osx.h> | ||
| # endif | ||
| #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) | ||
| # include <bee/async/async_bsd.h> | ||
| #endif | ||
|
|
||
| namespace bee::async { | ||
|
|
||
| #if defined(__linux__) | ||
|
|
||
| class async { | ||
| public: | ||
| virtual ~async() = default; | ||
| virtual bool submit_read(net::fd_t fd, void* buffer, size_t len, uint64_t request_id) = 0; | ||
| virtual bool submit_readv(net::fd_t fd, span<const net::socket::iobuf> bufs, uint64_t request_id) = 0; | ||
| virtual bool submit_write(net::fd_t fd, const void* buffer, size_t len, uint64_t request_id) = 0; | ||
| virtual bool submit_writev(net::fd_t fd, span<const net::socket::iobuf> bufs, uint64_t request_id) = 0; | ||
| virtual bool submit_accept(net::fd_t listen_fd, uint64_t request_id) = 0; | ||
| virtual bool submit_connect(net::fd_t fd, const net::endpoint& ep, uint64_t request_id) = 0; | ||
| virtual bool submit_file_read(file_handle::value_type fd, void* buffer, size_t len, int64_t offset, uint64_t request_id) = 0; | ||
| virtual bool submit_file_write(file_handle::value_type fd, const void* buffer, size_t len, int64_t offset, uint64_t request_id) = 0; | ||
| virtual bool submit_poll(net::fd_t fd, uint64_t request_id) = 0; | ||
| virtual int poll(const span<io_completion>& completions) = 0; | ||
| virtual int wait(const span<io_completion>& completions, int timeout) = 0; | ||
| virtual void stop() = 0; | ||
| virtual void cancel(net::fd_t fd) = 0; | ||
| }; | ||
|
|
||
| #endif | ||
|
|
||
| // Factory function: create the async backend for the current platform. | ||
| std::unique_ptr<async> create(); | ||
|
|
||
| } // namespace bee::async | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.