Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4e38062
新增跨平台异步IO模块
actboy168 Apr 12, 2026
b344d13
Update meta/async.lua
actboy168 Apr 14, 2026
446d656
refactor: 简化 read 逻辑并优化 buf_unpin 与 commit 调用
actboy168 Apr 14, 2026
6e1152e
fix: expand poll/wait return type annotation to include string for fi…
Copilot Apr 14, 2026
258cf83
Update bee/async/async_uring_linux.cpp
actboy168 Apr 14, 2026
bb8518a
refactor: 简化异步IOURING初始化逻辑并明确内核特性要求
actboy168 Apr 14, 2026
a9330ff
refactor: 动态设置 io_uring_enter 的 arg 大小以提升灵活性
actboy168 Apr 14, 2026
185b2df
Update test/test_async.lua
actboy168 Apr 14, 2026
a1c82ac
refactor: 优化epoll操作前置校验与防重复提交
actboy168 Apr 14, 2026
41eaeb1
docs: 更新 cancel 函数注释说明为空操作及取消要求
actboy168 Apr 14, 2026
77f0d0e
feat: 新增 op_filter 并完善 kqueue 事件取消防 use-after-free
actboy168 Apr 14, 2026
023b9e3
refactor: 移除 pending_op 结构体及相关动态分配逻辑
actboy168 Apr 14, 2026
8b684aa
refactor: 修正环形缓冲区大小计算并兼容32/64位平台
actboy168 Apr 14, 2026
4b5f638
refactor: 添加异步请求资源清理与缓冲区释放
actboy168 Apr 14, 2026
40dace1
refactor: 重构异步事件处理,增强虚假唤醒检测与重注册可靠性
actboy168 Apr 14, 2026
ca52017
feat: 异步文件写入绑定buf防释放并完善错误处理
actboy168 Apr 14, 2026
6aab683
refactor: 引入luaref机制重构异步IO引用管理
actboy168 Apr 14, 2026
addbfc1
refactor: 重构异步操作机制,改用 packed_id 统一管理请求与引用
actboy168 Apr 14, 2026
4438893
refactor: 重构net_async读逻辑并统一常量与字段命名
actboy168 Apr 14, 2026
9859340
feat: 新增异步读多缓冲区支持
actboy168 Apr 14, 2026
aff593b
feat: 新增异步分散读支持及 read/readv 双分支处理
actboy168 Apr 15, 2026
06703a1
Update binding/lua_async.cpp
actboy168 Apr 15, 2026
f1b304d
refactor: 统一将 io_uring 相关标识及结构体前缀由 UV__ 改为 BEE__
actboy168 Apr 15, 2026
0d413bc
fix: 修正 io_uring_enter 重试条件并统一中断
actboy168 Apr 15, 2026
c17f000
feat: 新增 io_uring 超时处理及内部 timeout 类型支持
actboy168 Apr 15, 2026
5edf2a6
feat: 增强 Windows 异步操作支持,新增监听套接字与上下文更新
actboy168 Apr 15, 2026
ab6022b
Update meta/async.lua
actboy168 Apr 15, 2026
c6af582
refactor: 优化 submit_write 实现,新增 sqe 获取与发送逻辑
actboy168 Apr 15, 2026
55e23a6
feat: 新增SO_UPDATE_ACCEPT/CONNECT_CONTEXT宏并移除mstcpip/mswsock依赖
actboy168 Apr 15, 2026
21a3ec1
refactor: 清理并统一 Windows 异步 IO 扩展函数引用
actboy168 Apr 15, 2026
e5ed2fb
Update test/test_async.lua
actboy168 Apr 15, 2026
56958fe
fix: 修复wb_submit_all失败时资源泄漏与状态不一致问题
actboy168 Apr 15, 2026
29bffa4
fix: 修复 wait_completion 返回值并增加操作类型 op
actboy168 Apr 15, 2026
db4ab1d
refactor: 重构 wait_accept 签名并清理冗余 associate 调用
actboy168 Apr 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions bee/async/async.cpp
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
53 changes: 53 additions & 0 deletions bee/async/async.h
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;
Comment thread
actboy168 marked this conversation as resolved.
};

#endif

// Factory function: create the async backend for the current platform.
std::unique_ptr<async> create();

} // namespace bee::async
Loading
Loading