alibaba / async_simple
Simple, light-weight and easy-to-use asynchronous components
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing alibaba/async_simple in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewasync_simple A Simple, Light-Weight Asynchronous C++ Framework English | 中文 async_simple is a library offering simple, light-weight and easy-to-use components to write asynchronous code. The components offered include Lazy (based on C++20 stackless coroutine), Uthread (based on stackful coroutine) and the traditional Future/Promise. Quick Experience We can try async_simple online in compiler-explorer. Note that cannot be use in compiler-explorer since it requires installation. Get Started Our documents are hosted by GitHub Pages, go to Get Started. After installing and reading Lazy to get familiar with API, here is a demo use Lazy to count char in a file. Install async_simple By Vcpkg vcpkg is a cross-platform package manager. By Cmake Import async_simple After install async_simple, you can import it to your project. By cmake find_package Please add those cmake code: is the target name which want to use async_simple Manually async_simple is almost header-only. So you can just pass the include path of the install position to your compiler. But the uthread part of async_simple is not head-only. If you want to use uthread, You need link it manually. The library file is in the install path. Compiler Requirement Required Compiler: clang (>= 10.0.0) or gcc (>= 10.3) or Apple-clang (>= 14) Note that we need to add the option when we use gcc 12 due to a false positive diagnostic message by gcc 12 If you're using , there may be some compiler bugs in clang15. We suggest to use clang17 or higher for that. If you meet any problem about MSVC Compiler Error C4737. Try to add the /EHa option to fix the problem. Develop async_simple The build of async_simple requires libaio, googletest and cmake. Both libaio and googletest are optional. (Testing before using is highly suggested.) By default, async_simple would try to clone the googletest from git to make sure the version used is correct. But in case the users have problems with networks, users can try to install the gtest libraries by the following instructions and use the CMake variables ('GMOCK_INCLUDE_DIR', 'GTEST_LIBRARIES', 'GMOCK_INCLUDE_DIR', 'GMOCK_LIBRARIES') to specify the location. Using apt (Ubuntu and Debian) • Use to install gtest and gmock • Try to build gtest and gmock from source Using yum (CentOS and Fedora) • Use to install gtest, gmock • Try to build gtest and gmock from source Using Pacman (Arch) Using Homebrew (macOS) Windows Build Dependencies From Source Demo example dependency Demo example depends on standalone asio(https://github.com/chriskohlhoff/asio/tree/master/asio), the commit id:f70f65ae54351c209c3a24704624144bfe8e70a3 Build cmake Conan is also supported. You can install async_simple to conan local cache. bazel • See this to get more information • Indicates recursively scan all targets, recognized as in , can be replaced by other or to run, such as or use • Use as a dependency, see also bazel support Docker Compile Environment Performance We also give a Quantitative Analysis Report of Lazy (based on C++20 stackless coroutine) and Uthread (based on stackful coroutine). C++20 Modules Support We have **experimental** support for C++20 Modules in . We can build the module by and . We can find the related usage in , , and . We need clang (>= d18806e6733 or simply clang 16) to build the module. It is only tested for libstdc++10.3. Due to the current support status for C++20, it won't be a surprise if the compilation fails in higher versions of STL. We can build the module with xmake (>= 0eccc6e) using the commands: We can build the module with cmake (>= d18806e673 or cmake 3.26 and up) using the following commands: If std module is available, we can define when configuring cmake to use std modules provided by vendors. **Note** that the module in the main branch is actually a named module's wrapper for headers for compatibility. We can find the practical usage of C++20 Modules in https://github.com/alibaba/async_simple/tree/CXX20Modules, which contains the support for xmake and cmake as well. Questions For questions, we suggest to read docs, issues and discussions first. If there is no satisfying answer, you could file an issues or start a thread in discussions. Specifically, for defect report or feature enhancement, it'd be better to file an issues. And for how-to-use questions, it'd be better to start a thread in discussions. How to Contribute • Read the How to fix issue document firstly. • Run tests and locally for the change. Note that the version of clang-format in CI is clang-format 14. So that it is possible your local format result is inconsistency with the format result in the CI. In the case, you need to install the new clang-format or adopt the suggested change by hand. In case the format result is not good, it is OK to accept the PR temporarily and file an issue for the clang-formt. • Create a PR, fill in the PR template. • Choose one or more reviewers from contributors: (e.g., ChuanqiXu9, RainMark, foreverhy, qicosmos). • Get approved and merged. License async_simple is distributed under the Apache License (Version 2.0) This product contains various third-party components under other open source licenses. See the NOTICE file for more information.