Skip to content

pointertobios/asco

Repository files navigation

ASCO

MIT License

基于 C++20 coroutine 的异步框架 (需要 C++23 支持).

开始使用

快速开始

依赖目标 asco::main:

#include <print>
#include <asco/future.h>

using namespace asco;

future<void> foo() {
    std::println("foo() called");
    co_return;
}

future<int> async_main() { // asco::main 提供的入口
    auto f = foo();
    std::println("async_main() running");
    co_await f;
    std::println("foo() completed");
    co_return 0;
}

文档

导入到你的项目

作为 Git 子模块

  1. 将本仓库添加为 Git 子模块
  2. 用 cmake 导入:
  • 静态链接:
add_subdirectory(<path-to-this-repo>)
target_link_libraries(<your-target> PRIVATE asco::core asco::main)
  • 动态链接:
add_subdirectory(<path-to-this-repo>)
target_link_libraries(<your-target> PRIVATE asco::shared::core asco::shared::main)

用 cmake FetchContent_Declare() 导入

include(FetchContent)

FetchContent_Declare(
    asco
    GIT_REPOSITORY https://github.com/pointertobios/asco.git
    GIT_TAG <version-tag>
)
FetchContent_MakeAvailable(asco)

功能特性

非叶子项打 ✔ 表示特性已可用但可能不完整

  • 异步运行时
    • Linux 完整支持
    • Windows 完整支持
    • MacOS 完整支持
    • 核心运行时
      • 线程池 runtime
      • 任务取消机制
      • 动态优先级
      • 异步任务本地存储
      • 任务偷窃
      • 计时器
        • 高分辨率计时器
        • 时间轮
      • IO 兼容层
        • io_uring (Linux)
        • Epoll (Linux)
        • IOCP (Windows)
  • 测试框架
  • 并发
    • 同步原语
      • 自旋锁
      • 信号量
        • 任务取消支持
      • 通道
        • 任务取消支持
      • 互斥锁
        • 任务取消支持
      • 读写锁
        • 任务取消支持
      • 条件变量
        • 任务取消支持
      • 屏障
        • 任务取消支持
      • 门闩
        • 任务取消支持
    • 定时器与超时
      • 任务取消支持
    • 无锁数据结构与算法
      • 环形队列
      • 双端队列
  • 异步 IO
    • 文件
    • 网络
    • 远程过程调用(RPC)

编译器支持

  • Clang: 完整支持
  • GCC: 不完全支持
  • MSVC: 仅支持 VS 2026 及以上版本的 clang 模式

开发与贡献

阅读 CONTRIBUTING.md 了解详情。

License

本项目使用 MIT License 发布.

Copyright (C) 2025 pointer-to-bios pointer-to-bios@outlook.com

完整的法律条款参见 LICENSE

About

Coroutine based async framework.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors