English | 中文
The async_simple is a library offering simple, light-weight and easy-to-use components to write asynchronous codes. The components offered include the Lazy (based on C++20 stackless coroutine), the Uthread (based on stackful coroutine) and the traditional Future/Promise.
The build of async_simple need libaio, googletest and cmake. Both libaio and googletest are optional. (Testing before using is highly suggested.)
# Install libaio sudo apt install libaio-dev -y # Install cmake sudo apt install cmake -y # Install bazel See: https://bazel.build/install/ubuntu- using
aptto install gtest, gmock
sudo apt install -y libgtest-dev libgmock-dev# Install gtest sudo apt install libgtest-dev -y sudo apt install cmake -y cd /usr/src/googletest/gtest sudo mkdir build && cd build sudo cmake .. && sudo make install cd .. && sudo rm -rf build cd /usr/src/googletest/gmock sudo mkdir build && cd build sudo cmake .. && sudo make install cd .. && sudo rm -rf build # Install bazel See: https://bazel.build/install/ubuntu# Install libaio sudo yum install libaio-devel -y- Using
yumto install gtest, gmock
sudo yum install gtest-devel gmock-devel # Optional sudo pacman -S libaio # Use cmake to build project sudo pacman -S cmake gtest # Use bazel to build project sudo pacman -S bazel# Use cmake to build project brew install cmake brew install googletest # Use bazel to build project sudo pacman -S bazel# Install cmake winget install cmake # Install google-test # TODO # Install bazel See: https://bazel.build/install/windows# libaio (optional) # you can skip this if you install libaio from packages git clone https://pagure.io/libaio.git cd libaio sudo make install # gmock and gtest git clone git@github.com:google/googletest.git -b v1.8.x cd googletest mkdir build && cd build cmake .. && sudo make install Required Compiler: clang (>= 13.0.0) or gcc (>= 10.3)
Demo example depends on standalone asio(https://github.com/chriskohlhoff/asio/tree/master/asio), the commit id:f70f65ae54351c209c3a24704624144bfe8e70a3
$ mkdir build && cd build # Specify [-DASYNC_SIMPLE_ENABLE_TESTS=OFF] to skip tests. # Specify [-DASYNC_SIMPLE_BUILD_DEMO_EXAMPLE=OFF] to skip build demo example. # Specify [-DASYNC_SIMPLE_DISABLE_AIO=ON] to skip the build libaio CXX=clang++ CC=clang cmake ../ -DCMAKE_BUILD_TYPE=[Release|Debug] [-DASYNC_SIMPLE_ENABLE_TESTS=OFF] [-DASYNC_SIMPLE_BUILD_DEMO_EXAMPLE=OFF] [-DASYNC_SIMPLE_DISABLE_AIO=ON] # for gcc, use CXX=g++ CC=gcc make -j4 make test # optional make install # sudo if requiredConan is also supported. You can install async_simple to conan local cache.
mkdir build && cd build conan create .. # Specify [--define=ASYNC_SIMPLE_DISABLE_AIO=true] to skip the build libaio # Example bazel build --define=ASYNC_SIMPLE_DISABLE_AIO=true ... bazel build ... # compile all target bazel build ...:all # compile all target bazel build ...:* # compile all target bazel build -- ... -benchmarks/... # compile all target except those beneath `benchmarks` bazel test ... # compile and execute tests # Specify compile a target # Format: bazel [build|test|run] [directory name]:[binary name] # Example bazel build :async_simple # only compile libasync_simple bazel run benchmarks:benchmarking # compile and run benchmark bazel test async_simple/coro/test:async_simple_coro_test # Use clang toolchain bazel build --action_env=CXX=clang++ --action_env=CC=clang ... # Add compile option bazel build --copt='-O0' --copt='-ggdb' ...- See this get more infomation
...Indicates recursively scan all targets, recognized as ../.. inoh-my-zsh, can be replaced by othershellorbash -c 'commond'to run, such asbash -c 'bazel build' ...or usebazel build ...:all
After installing and reading Lazy to get familiar with API, here is a demo use Lazy to count char in a file.
We also give a Quantitative Analysis Report Of the Lazy (based on C++20 stackless coroutine) and the Uthread (based on stackful coroutine).
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.
- Read the How to fix issue document firstly.
- Run tests and
git-clang-format HEAD^locally for the change. - 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.
Please scan the following QR code of DingTalk to contact us.
We could monitor the performance change history in: https://alibaba.github.io/async_simple/benchmark-monitoring/index.html.
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.
