Merged
feat(a2a): a2a support macos #351
feat(a2a): a2a support macos #351
Merged
zhuyutong888Add on 29 days ago
zhuyutong888Collaborators
29 days ago

Paired: GitHub #147 ↔ GitCode !351

What type of PR is this?

/kind feature

Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)

Linked Closing Issues:
https://gitcode.com/openJiuwen/agent-protocol/issues/33

Linked Closing Issues:

likedislike
Pull Request has been successfully merged by openJiuwen-bot.
(Thank you for zhuyutong888's contribution.)
Zzhuyutong888Collaborators
29 days ago Associated issue: [Feature] 增加 macOS 平台构建支持与 CI 覆盖,补齐跨平台能力短板
atomgit-bot
atomgit-bot
29 days ago Comments:

变更摘要

本 PR 为 A2A C++ SDK 引入 macOS 平台支持(基于 libevent 事件循环),核心是新增 platform_compat.h 平台兼容层,将原先 Linux 专属的系统调用(syscall(SYS_gettid)、eventfd、TCP_KEEPIDLE、pthread_setname_np 单参形式等)统一封装并按平台分支实现。EventSystem 的 notifyChannel 从裸 eventfd 重构为跨平台的 Platform::NotifyChannel(Linux 用 eventfd,其它平台用非阻塞管道加软件计数器),A2ATimer 则彻底放弃自建 epoll 循环,改为复用 A2A::EventSystem 的定时器能力。构建与运行脚本同步适配 macOS 的依赖安装、动态库路径、超时命令与 ASAN 差异。

主要改动

  • 新增平台兼容层 platform_compat.h: 提供 GetThreadId、SetCurrentThreadName、SetKeepAliveIdle/Intvl/Cnt 以及跨平台通知通道 NotifyChannel(CreateNotifyChannel/NotifyChannelNotify/NotifyChannelRead/CloseNotifyChannel/ReadChannelFdRaw),在 __linux__、__APPLE__ 等分支下分别使用 eventfd/syscall 与 pipe+软件计数器实现。

  • EventSystem 通知机制重构: CreateNotifyEventId 改用 Platform::CreateNotifyChannel,NotifyEventId/ReadEventFd/析构及 RemoveEventInternal 改为通过 NotifyChannel 读写与释放 fd,并在 EventData 中新增 notifyChannel 字段;mutex_ 改为 mutable std::mutex 以支持 ReadEventFd 中的加锁查找。

  • A2ATimer 改用 EventSystem 驱动: 移除自建的 epoll/eventfd 循环(Init、RunLoop、GetNextTimeout、HandleExpired 被删除),TimerTask 以 eventId 替代过期时间点,AddTimer/RefreshTimer/CancelTimer 通过 EventSystem::AddTimer/RemoveEvent 调度,并新增 EnsureStarted、OnTimerFired、OnKeepAlive 及 keepAliveEventId_ 维持事件循环存活。

  • 日志与线程工具接入兼容层: a2a_log.h 移除 sys/syscall.h,改为通过新增的 GetCurrentThreadId() 调用 Platform::GetThreadId();thread_utils.h 的 SetCurrentThreadName 委托给 Platform::SetCurrentThreadName,从而兼容 macOS 的 pthread_setname_np 单参签名。

  • 脚本与测试适配 macOS: install_deps.sh 增加 Darwin 平台识别与 Homebrew 依赖检查/安装流程,run_example.sh/run_ut.sh 区分 DYLD_LIBRARY_PATH/LD_LIBRARY_PATH 并用 gtimeout 兜底、跳过 macOS 上的 ASAN 预加载;UT 中 eventfd 相关用例加 __linux__ 条件编译,改用 fcntl 设置非阻塞并调整 SO_REUSEPORT 与 EventSystem 线程模式断言。

likedislike
Incorrect?
atomgit-bot
atomgit-bot
29 days ago Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
OopenJiuwen-botCollaborators
29 days ago Set YiyangShao,xinyu-jiuwen as approver
atomgit-bot
atomgit-bot
29 days ago Comments:

AtomGit AI 助手使用指南

在 PR 评论中使用命令即可触发。支持在普通评论和代码行评论中使用。

功能 命令 说明
代码审查 /ai review 检查代码质量、潜在问题、安全风险
PR 摘要 /ai summary 生成 PR 变更内容的结构化摘要
代码解释 /ai explain 解释代码变更的逻辑和意图
自由提问 @atomgit-bot <问题> 询问关于本 PR 的任何问题
帮助 /ai help 显示此帮助信息

免责声明

AI 助手可能存在误判,请结合自身判断。可以对评论点 👍 或 👎 帮助我们改进。

likedislike
Incorrect?
217 messages are collapsed here。 See more
OopenJiuwen-botCollaborators
20 days ago Added label: approvedlgtm-mingo007
openJiuwen-botCollaborators
20 days ago Comments:

Review Code Feedback

  • The label lgtm-mingo007, approved was added to this pull request. It means that mingo007 reviewed the code changes. 👋
Tips
  • If this pull request is not merged while all conditions are met, comment /check-pr to try again. 😄
likedislike
OopenJiuwen-botCollaborators
20 days ago Closed associated issue
OopenJiuwen-botCollaborators
20 days ago Merged pull request
OopenJiuwen-botCollaborators
20 days ago Removed label: ci-successful