Git Product home page Git Product logo

async_simple's Introduction

async_simple

A Simple, Light-Weight Asynchronous C++ Framework

license language feature last commit

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: https://compiler-explorer.com/z/Tdaesqsqj . Note that Uthread 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.

./vcpkg install async-simple

By Cmake

git clone -b main --single-branch --depth 1 https://github.com/alibaba/async_simple.git
cd async_simple
mkdir build
cd build
cmake .. -DASYNC_SIMPLE_ENABLE_TESTS=OFF -DASYNC_SIMPLE_BUILD_DEMO_EXAMPLE=OFF -DASYNC_SIMPLE_ENABLE_ASAN=OFF
cmake --build .
cmake --install . # --prefix ./user_defined_install_path 

Import async_simple

After install async_simple, you can import it to your project.

By cmake find_package

please add those cmake codes:

find_package(async_simple REQUIRED)
target_link_libraries(<your-target-name> PRIVATE async_simple::async_simple) # dynamic_link
                                 # async_simple::async_simple_header_only   
                                 # async_simple::async_simple_static  

<your-target-name> is the target name which want to use async_simple

Manully

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 manully. 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 -Wno-maybe-uninitialized option when we use gcc 12 due to a false positive diagnostic message by gcc 12

If you're using async_simple::Generator, 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)

# Install libaio
sudo apt install libaio-dev -y
# Install cmake
sudo apt install cmake -y
# Install bazel See: https://bazel.build/install/ubuntu
  • Use apt to install gtest and 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

Using yum (CentOS and Fedora)

# Install libaio
sudo yum install libaio-devel -y
  • Use yum to install gtest, gmock
sudo yum install gtest-devel gmock-devel

Using Pacman (Arch)

# Optional
sudo pacman -S libaio
# Use cmake to build project
sudo pacman -S cmake gtest
# Use bazel to build project
sudo pacman -S bazel

Using Homebrew (macOS)

# Use cmake to build project
brew install cmake
brew install googletest
# Use bazel to build project
brew install bazel

Windows

# Install cmake
winget install cmake
# Install google-test
# TODO
# Install bazel See: https://bazel.build/install/windows

Build Dependencies From Source

# 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 [email protected]:google/googletest.git -b v1.8.x
cd googletest
mkdir build && cd build
cmake .. && sudo make install

Demo example dependency

Demo example depends on standalone asio(https://github.com/chriskohlhoff/asio/tree/master/asio), the commit id:f70f65ae54351c209c3a24704624144bfe8e70a3

Build

cmake

$ 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] [-DGMOCK_INCLUDE_DIR=<path-to-headers of gtest> -DGTEST_INCLUDE_DIR=<path-to-headers of mock> -DGTEST_LIBRARIES=<path-to-library-of-gtest>  -DGMOCK_LIBRARIES=<path-to-library-of-gmock> ]
# for gcc, use CXX=g++ CC=gcc
make -j4
make test # optional
make install # sudo if required

Conan is also supported. You can install async_simple to conan local cache.

mkdir build && cd build
conan create ..

bazel

# 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 ../.. in oh-my-zsh, can be replaced by other shell or bash -c 'commond' to run, such as bash -c 'bazel build' ... or use bazel build ...:all
  • Use async_simple as a dependency, see also bazel support

Docker Compile Environment

git clone https://github.com/alibaba/async_simple.git
cd async_simple/docker/(ubuntu|centos7|rockylinux)
docker build . --no-cache -t async_simple:1.0
docker run -it --name async_simple async_simple:1.0 /bin/bash

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 modules/async_simple.cppm. We can build the async_simple module by xmake and cmake. We can find the related usage in CountChar, ReadFiles, LazyTest.cpp and FutureTest.cpp.

We need clang (>= d18806e6733 or simply clang 16) to build the async_simple 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 async_simple module with xmake (>= 0eccc6e) using the commands:

xmake

We can build the async_simple module with cmake (>= d18806e673 or cmake 3.26 and up) using the following commands:

mkdir build_modules && cd build_modules
CC=clang CXX=clang++ cmake .. -DCMAKE_BUILD_TYPE=Release -DASYNC_SIMPLE_BUILD_MODULES=ON -GNinja
ninja

Note that the async_simple module in the main branch is actually a named module's wrapper for headers for compatability. 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

  1. Read the How to fix issue document firstly.
  2. Run tests and git-clang-format HEAD^ 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.
  3. Create a PR, fill in the PR template.
  4. Choose one or more reviewers from contributors: (e.g., ChuanqiXu9, RainMark, foreverhy, qicosmos).
  5. Get approved and merged.

Contact us

Please scan the following QR code of DingTalk to contact us.

dingtalk

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.

async_simple's People

Contributors

4kangjc avatar alibaba-oss avatar bbbgan avatar chloro-pn avatar chuanqixu9 avatar devillove084 avatar faker2048 avatar fananchong avatar fantasy-peak avatar foreverhy avatar laitingsheng avatar lindhw avatar morebtcg avatar pikachuhy avatar pikachuhya avatar pokisemaine avatar poor-circle avatar qicosmos avatar rainmark avatar star-hengxing avatar stephenri avatar tchaikov avatar uniqss avatar wangtz0607 avatar waruqi avatar yanminhui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

async_simple's Issues

replace usleep for cross platform support

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

use std::this_thread::sleep_for to replace all usleep

previous discuss at: #51 (comment)

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

We need benchmark CI

Search before asking

  • I searched the issues and found no similar issues.

What

We need a benchmarking CI to monitoring the performance changes.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

lazy.start() captured exception by default

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

lazy.start() captured exception by default and pass Try to user callback
user maybe forget to process exception, caused user's coroutine code can not finish, and the resource leaked.

make lazy.start() throw exception by default?

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

How to fix issue

Create documents to tell developers how to fix an existing issue.

Add Chinese README

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Add Chinese readme document and introduce Alibaba scene.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Handle executor's schedule/checkin return value

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

pr._ex->checkin(func, _ctx);

If executor's checkin method returned false and task not be executed, this may caused the lazy can not resumed.
We should handle the return value, how about to add the logicAssert?

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Add document for windows

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Although we've accepted #84, we lack a document for it.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

assign a Promise to another existing Promise cause ref count leak

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

The Promise copy assignment implement missing invoke detachPromise()

Reproduction way

We construct a unit test, expect to got "Promise is broken" exception, but it's failed

    auto promise1 = std::make_unique<Promise<int>>();
    auto promise2 = std::make_unique<Promise<int>>();
    promise2->setValue(0);
    auto future = promise1->getFuture();
    *promise1 = *promise2;
    promise1.reset();
    ASSERT_THROW(future.value(), std::runtime_error);

Anything else

I try to delete the Promise's copy assignment operator, but failed.
Looks like Executor::schedule(Func func) broken the promise's move construct if promise object captured by lambda.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Adding executor parameter to async_simple::coro::LazyHelper

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

In #100, we found the user forget to pass in an executor. The suggested use is:

syncAwait(lazy_func().via(executor));

But it might not be straight forward. It would be better to add a default parameter 'executor' to syncAwait.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

make test receive that error!

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

root@win10:/home/Project/async_simple/build# make test
Running tests...
Test project /home/Project/async_simple/build
Start 1: run_async_simple_test
1/5 Test #1: run_async_simple_test ............ Passed 2.73 sec
Start 2: run_async_simple_util_test
2/5 Test #2: run_async_simple_util_test ....... Passed 0.02 sec
Start 3: run_async_simple_coro_test
3/5 Test #3: run_async_simple_coro_test .......***Failed 37.21 sec
Start 4: run_async_simple_executor_test
4/5 Test #4: run_async_simple_executor_test ... Passed 1.07 sec
Start 5: run_async_simple_uthread_test
5/5 Test #5: run_async_simple_uthread_test .... Passed 3.95 sec

80% tests passed, 1 tests failed out of 5

Total Test time (real) = 44.99 sec

The following tests FAILED:
3 - run_async_simple_coro_test (Failed)
Errors while running CTest

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Remove util/Condition.h

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

util/Condition.h like c++ std::condition_variable, we better use std::condition_variable to keep cross platform

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Add format tool to CI

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

If the code is not formatted, the CI should report it.

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

We need AsyncGenerator

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Generator is an important use case and we should support it in async_simple.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Undefined Behavior to access non active union member

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Extract from: https://www.reddit.com/r/cpp/comments/ta4h29/async_simple_a_c20_coroutine_library/:

ContextUnion u;
u.ctx = ctx;

auto prompt =
    _pool.getCurrentId() == (u.id & 0xBFFFFFFF) && opts.prompt;

It is undefined behavior, access to non active union member

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Remove uthread related implement in Future

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Like title

Anything else

Future<T> foo();

// uthread context

T bar() {
   // old usage
  // return foo().get();
  
  // new usage
  return await(foo());
}

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Avoid User Write Awaiter

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

After user used Lazy , they have to write many Awaiter to adapt the exist callback type asynchronous APIs
We can introduce a FutureAwaiter to avoid it.

eg:

template <typename T>
class FutureAwaiter {
public:
    FutureAwaiter() {
        _fut = _pr.getFuture();
    }
    void setValue(T&& value) {
        _pr.setValue(std::move(value));
    }


    bool await_ready() {
        return _fut.hasResult();
    }
    void await_suspend(impl::coroutine_handle<> h) {
        auto func = [h](Try<T>&& t) mutable {
            h.resume();
        };
        std::move(_fut).thenTry(std::move(func));
    }
    T&& await_resume() { return std::move(_fut.value()); }

private:
    Promise<T> _pr;
    Future<T> _fut;
};

// exist callback style asynchronous api
template <typename Callback>
void asyncTask(CallBack&& cb) {
    // ...
    cb(0);
}

// use example

Lazy<int> asyncTaskCoro() {
    FutureAwaiter awaiter;
    asyncTask([&awaiter](auto result) {
                  awaiter.setValue(result);
              });
    int ret = co_await awaiter;
    co_return ret;
}

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

redifinition of struct hash<coroutine_handle<_Tp> >

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

I'm on MacOS and I use g++-11 (11.2.0) for both CXX and CC. I come across the error when build.

/async_simple/async_simple/experimental/coroutine.h:400:8: error: 
      redefinition of 'hash<coroutine_handle<_Tp> >'
struct hash<coroutine_handle<_Tp> > {
/include/c++/v1/experimental/coroutine:323:8: note: 
      previous definition is here
struct hash<_VSTD_CORO::coroutine_handle<_Tp> > {

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Add cmake parameter to avoid compiling test?

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

It needs GTEST when compiling,But many people only want compiled libraries

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

demo_example/smtp_client compile failed on clang11/gcc8.3

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

[ 88%] Linking CXX executable smtp_client
/usr/bin/ld: CMakeFiles/smtp_client.dir/smtp/smtp_client.cpp.o: in function `path<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::filesystem::__cxx11::path>':
/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/fs_path.h:184: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [demo_example/CMakeFiles/smtp_client.dir/build.make:86: demo_example/smtp_client] Error 1
make[1]: *** [CMakeFiles/Makefile2:788: demo_example/CMakeFiles/smtp_client.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 98%] Built target async_simple_coro_test
make: *** [Makefile:141: all] Error 2

Reproduction way

root@1930998036fd:/Users/rain/Project/async_simple/build# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6)


root@1930998036fd:/Users/rain/Project/async_simple/build# clang -v
clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

SegmentFault when using coro::SpinLock

Hi I was trying to add concurrency to the async_echo_client.cpp, so the socket send/recv would need lock projection.

However I met a SegmentFault when using coro::SpinLock, see #99

Remove MoveWrapper

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

remove MoveWrapper.h
the following usage is so ugly

Promise p;
auto func = [wrapper = MoveWrapper(std::move(p))]() {
  wrapper.get().setValue()
}

Anything else

TODO

See: #20

  • Remove Promise's copy assignment operator, remove promiseRef_ member in FutureState.h
  • Delete MoveWrapper.h
  • Try to fix the problem of std::function require the captured object be copyable

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Support GCC

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

async_simple only support clang now, we also need to support gcc.

Reproduction way

Anything else

#25

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Remove Task<>

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Task was designed for pure in-memory applications(for some historical issues), nobody is actually using it, consider remove from this library.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

optimize lazy collectAll implement

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

detail::CollectAnyAwaiter<LazyType<T>, IAlloc>>;

Lazy<> foo() {}

collectAll(foo().via(executor)) is equal to collectAllPara(foo())

maybe we can use collectAll(foo().via(executor)) to simplify the collectAllPara, for example: collectAllPara call collectAll(foo().via(executor)) directly

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Cleanup Executor.h

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

The Executor.h's syncSchedule() and Awaitable schedule(); method never used, we should delete it?

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Difference between `Lazy` and `asio::awaitable` or `asio::experimental::coro` ?

What happened

It is well known that asio provides several ways to perform io operations, i.e. synchronous, asynchronous by callback or (chained) future, asynchronous by stackful coroutines (with boost::coroutine2 or boost::fiber) and asynchronous by stackless coroutines (with asio::awaitable or the newer asio::experimental::coro for c++20 coroutines).
So I just wonder the relationship between Lazy provided by this library and them, especially what advantages does this library have over those boost things?

(difference between asio::awaitable and asio::experimental::coro: the former is literally just awaitable, while the latter can be an async generator.)

The series function of collect* cause segment fault when param is a right reference to temporary object

Search before asking

  • [✔] I searched the issues and found no similar issues.

What happened + What you expected to happen

The function collectAll/Any... cause segment fault when param is a right reference to temporary object.

Reproduction way

Just use temporary object as param in coroutine context.

collectAll(Lazy<int>{},Lazy<float>{});
collectAll(std::vector<Lazy<int>>{});
//....

Are you willing to submit a PR?

  • [✔ ] Yes I am willing to submit a PR!

[Bug]Memory Leak in Future_chain benchmark

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Run benchmark on debug mode, there will be memory leaks error from LeakSanitizer:

==63002==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 888 byte(s) in 111 object(s) allocated from:
    #0 0x5d7228 in operator new(unsigned long) (/home/admin/code/async_simple/build/benchmarks/benchmarking+0x5d7228)
    #1 0x11de2eb in __gnu_cxx::new_allocator<int>::allocate(unsigned long, void const*) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/ext/new_allocator.h:114:27
    #2 0x11de290 in std::allocator_traits<std::allocator<int> >::allocate(std::allocator<int>&, unsigned long) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/alloc_traits.h:444:20
    #3 0x11dddff in std::_Vector_base<int, std::allocator<int> >::_M_allocate(unsigned long) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/stl_vector.h:343:20
    #4 0x11dd3d9 in void std::vector<int, std::allocator<int> >::_M_realloc_insert<int const&>(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/vector.tcc:440:33
    #5 0x11dd0b4 in std::vector<int, std::allocator<int> >::push_back(int const&) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/stl_vector.h:1195:4
    #6 0x11d2425 in Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(int)::operator()(int) const /home/admin/code/async_simple/benchmarks/Future.bench.cpp:38:19
    #7 0x11d365f in Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)::operator()(async_simple::Try<int>&&) const /home/admin/code/async_simple/benchmarks/Future.bench.cpp:48:26
    #8 0x11d45ce in std::enable_if<async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)>::ReturnsFuture::value, async_simple::Future<async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)>::ReturnsFuture::Inner> >::type async_simple::Future<int>::thenImpl<Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&), async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)> >(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)&&)::'lambda'(async_simple::Try<int>&&)::operator()(async_simple::Try<int>&&) /home/admin/code/async_simple/async_simple/Future.h:256:35
    #9 0x11d4459 in void async_simple::FutureState<int>::setContinuation<std::enable_if<async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)>::ReturnsFuture::value, async_simple::Future<async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)>::ReturnsFuture::Inner> >::type async_simple::Future<int>::thenImpl<Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&), async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)> >(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)&&)::'lambda'(async_simple::Try<int>&&)>(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&))::'lambda'(async_simple::Try<int>&&)::operator()(async_simple::Try<int>&&) /home/admin/code/async_simple/async_simple/FutureState.h:230:13
    #10 0x11d41c1 in std::_Function_handler<void (async_simple::Try<int>&&), void async_simple::FutureState<int>::setContinuation<std::enable_if<async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)>::ReturnsFuture::value, async_simple::Future<async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)>::ReturnsFuture::Inner> >::type async_simple::Future<int>::thenImpl<Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&), async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)> >(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&)&&)::'lambda'(async_simple::Try<int>&&)>(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda0'(async_simple::Try<int>&&))::'lambda'(async_simple::Try<int>&&)>::_M_invoke(std::_Any_data const&, async_simple::Try<int>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/std_function.h:300:2
    #11 0x11e1162 in std::function<void (async_simple::Try<int>&&)>::operator()(async_simple::Try<int>&&) const /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/std_function.h:688:14
    #12 0x11debcc in async_simple::FutureState<int>::scheduleContinuation(bool) /home/admin/code/async_simple/async_simple/FutureState.h:271:13
    #13 0x11df64f in async_simple::FutureState<int>::setResult(async_simple::Try<int>&&) /home/admin/code/async_simple/async_simple/FutureState.h:215:21
    #14 0x11df41c in async_simple::Promise<int>::setValue(async_simple::Try<int>&&) /home/admin/code/async_simple/async_simple/Promise.h:106:23
    #15 0x11d2c5a in std::enable_if<!(async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)>::ReturnsFuture::value), async_simple::Future<async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)>::ReturnsFuture::Inner> >::type async_simple::Future<int>::thenImpl<Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&), async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)> >(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)&&)::'lambda'(async_simple::Try<int>&&)::operator()(async_simple::Try<int>&&) /home/admin/code/async_simple/async_simple/Future.h:291:23
    #16 0x11d2b19 in void async_simple::FutureState<int>::setContinuation<std::enable_if<!(async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)>::ReturnsFuture::value), async_simple::Future<async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)>::ReturnsFuture::Inner> >::type async_simple::Future<int>::thenImpl<Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&), async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)> >(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)&&)::'lambda'(async_simple::Try<int>&&)>(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&))::'lambda'(async_simple::Try<int>&&)::operator()(async_simple::Try<int>&&) /home/admin/code/async_simple/async_simple/FutureState.h:230:13
    #17 0x11d2881 in std::_Function_handler<void (async_simple::Try<int>&&), void async_simple::FutureState<int>::setContinuation<std::enable_if<!(async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)>::ReturnsFuture::value), async_simple::Future<async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)>::ReturnsFuture::Inner> >::type async_simple::Future<int>::thenImpl<Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&), async_simple::TryCallableResult<int, Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)> >(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&)&&)::'lambda'(async_simple::Try<int>&&)>(Future_chain(benchmark::State&)::$_0::operator()() const::'lambda'(async_simple::Try<int>&&))::'lambda'(async_simple::Try<int>&&)>::_M_invoke(std::_Any_data const&, async_simple::Try<int>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/std_function.h:300:2
    #18 0x11e1162 in std::function<void (async_simple::Try<int>&&)>::operator()(async_simple::Try<int>&&) const /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/std_function.h:688:14
    #19 0x11e2279 in async_simple::FutureState<int>::scheduleContinuation(bool)::'lambda'()::operator()() /home/admin/code/async_simple/async_simple/FutureState.h:282:29
    #20 0x11e1f4c in std::_Function_handler<void (), async_simple::FutureState<int>::scheduleContinuation(bool)::'lambda'()>::_M_invoke(std::_Any_data const&) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/std_function.h:300:2
    #21 0x7f2883f41602 in std::function<void ()>::operator()() const /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/std_function.h:688:14
    #22 0x7f2883f4b254 in async_simple::util::WorkItem::process() /home/admin/code/async_simple/async_simple/util/ThreadPool.h:141:22
    #23 0x7f2883f48cdf in async_simple::util::ThreadPool::workerLoop(unsigned long) /home/admin/code/async_simple/async_simple/util/ThreadPool.h:381:19
    #24 0x7f2883f4c676 in void std::__invoke_impl<void, void (async_simple::util::ThreadPool::*&)(unsigned long), async_simple::util::ThreadPool*&, unsigned long&>(std::__invoke_memfun_deref, void (async_simple::util::ThreadPool::*&)(unsigned long), async_simple::util::ThreadPool*&, unsigned long&) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/invoke.h:73:14
    #25 0x7f2883f4c4b6 in std::__invoke_result<void (async_simple::util::ThreadPool::*&)(unsigned long), async_simple::util::ThreadPool*&, unsigned long&>::type std::__invoke<void (async_simple::util::ThreadPool::*&)(unsigned long), async_simple::util::ThreadPool*&, unsigned long&>(void (async_simple::util::ThreadPool::*&)(unsigned long), async_simple::util::ThreadPool*&, unsigned long&) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/invoke.h:95:14
    #26 0x7f2883f4c3f3 in void std::_Bind<void (async_simple::util::ThreadPool::* (async_simple::util::ThreadPool*, unsigned long))(unsigned long)>::__call<void, 0ul, 1ul>(std::tuple<>&&, std::_Index_tuple<0ul, 1ul>) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/functional:400:11
    #27 0x7f2883f4c25d in void std::_Bind<void (async_simple::util::ThreadPool::* (async_simple::util::ThreadPool*, unsigned long))(unsigned long)>::operator()<void>() /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/functional:482:17
    #28 0x7f2883f4c16c in void std::__invoke_impl<void, std::_Bind<void (async_simple::util::ThreadPool::* (async_simple::util::ThreadPool*, unsigned long))(unsigned long)> >(std::__invoke_other, std::_Bind<void (async_simple::util::ThreadPool::* (async_simple::util::ThreadPool*, unsigned long))(unsigned long)>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/invoke.h:60:14
    #29 0x7f2883f4c0fc in std::__invoke_result<std::_Bind<void (async_simple::util::ThreadPool::* (async_simple::util::ThreadPool*, unsigned long))(unsigned long)> >::type std::__invoke<std::_Bind<void (async_simple::util::ThreadPool::* (async_simple::util::ThreadPool*, unsigned long))(unsigned long)> >(std::_Bind<void (async_simple::util::ThreadPool::* (async_simple::util::ThreadPool*, unsigned long))(unsigned long)>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/invoke.h:95:14

SUMMARY: AddressSanitizer: 888 byte(s) leaked in 111 allocation(s).

Reproduction way

Run benchmark on debug mode.

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Add More Platform Support For Uthread

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

the low level context switch of uthread came from boost.context。
uthread only support x86_64 and arm currently, we can add more platform support with boost.context

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

[Dependency]Make libaio optional

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

libaio just used in example, so it can be optional to minimal dependency.

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Make SimpleExecutor configurable for WorkSteal and CoreBindings

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Currently the thread pool supports worksteal and corebindings, but the simple executor lacks interfaces to enable it. It is necessary to make SimpleExecutor configurable to enable these features.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

We need Bazel support

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Reproduction way

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Add the variadic overloaded to CollectAny

Search before asking

  • [✔] I searched the issues and found no similar issues.

What happened + What you expected to happen

Reproduction way

Anything else

Are you willing to submit a PR?

  • [✔] Yes I am willing to submit a PR!

build failed for stdc++?

Search before asking

done and found nothing helpful

What happened + What you expected to happen

2 problems

  • my version of googletest has change the name of gtest and gmock(yes, it maybe not a problem, I just found it change to googletest and googlemock) , and have no "install" for make,

image

although the gtrest may be build successfully, but not for the gmock as the following

root@ehicku20:/usr/src/googletest/googlemock/build# make
make[1]: *** No rule to make target '../googletest/CMakeFiles/gtest.dir/all', needed by 'CMakeFiles/gmock.dir/all'.  Stop.
make: *** [Makefile:84: all] Error 2
root@ehicku20:/usr/src/googletest/googlemock/build# make install
make: *** No rule to make target 'install'.  Stop.
  • failed to build for the last step, I tried to install the the lib "stdc++" , "apt-cache search stdc++" for lots of version, and installed some like "apt install libx32stdc++-9-dev-amd64-cross lib32stdc++-9-dev-amd64-cross" and some other versions, searched in google and found nothing else helpful, failed at last

image

Reproduction way

just do most steps as the instruction in the readme, my OS is ubuntu 20.04, and I installed clang11 clang12 for Rust some times ago.

Are you willing to submit a PR?

no

[Cross Platform]Support Windows

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

We have supported Mac, the next is Windows, at least make sure supporting Windows when using c++20 coroutine.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Infinite loop in benchmarks

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

It looks like the newest commit caused a infinite loop. See b7b5e1b for details

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

clang11 compile failed

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

/Users/rain/Project/async_simple/async_simple/experimental/coroutine.h:50:10: fatal error: 'version' file not found
#include <version>
         ^~~~~~~~~
In file included from /Users/rain/Project/async_simple/async_simple/uthread/internal/thread.cc:28:
In file included from /Users/rain/Project/async_simple/async_simple/uthread/internal/thread.h:30:
In file included from /Users/rain/Project/async_simple/async_simple/Future.h:19:
In file included from /Users/rain/Project/async_simple/async_simple/Executor.h:20:
/Users/rain/Project/async_simple/async_simple/experimental/coroutine.h:50:10: fatal error: 'version' file not found
#include <version>
         ^~~~~~~~~
1 error generated.
make[2]: *** [async_simple/CMakeFiles/async_simple_static.dir/build.make:78: async_simple/CMakeFiles/async_simple_static.dir/uthread/internal/thread.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:144: async_simple/CMakeFiles/async_simple_static.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Reproduction way

use clang11 build will get the error, the #include <version> file not exist in clang11?
comment the #include <version> can compile

clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

ThreadPool.h compile error

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

$ make -j4
[  1%] Building CXX object async_simple/CMakeFiles/async_simple_static.dir/executors/SimpleExecutor.cpp.o
[  3%] Building CXX object async_simple/CMakeFiles/async_simple.dir/executors/SimpleExecutor.cpp.o
[  5%] Building CXX object demo_example/CMakeFiles/smtp_client.dir/smtp/smtp_client.cpp.o
[  7%] Building CXX object demo_example/CMakeFiles/block_echo_client.dir/block_echo_client.cpp.o
In file included from In file included from /Users/rain/Project/async_simple/async_simple/executors/SimpleExecutor.cpp:/Users/rain/Project/async_simple/async_simple/executors/SimpleExecutor.cpp16::
16In file included from :
/Users/rain/Project/async_simple/async_simple/executors/SimpleExecutor.hIn file included from :/Users/rain/Project/async_simple/async_simple/executors/SimpleExecutor.h23::
23:
/Users/rain/Project/async_simple/async_simple/util/ThreadPool.h/Users/rain/Project/async_simple/async_simple/util/ThreadPool.h::7575::10:10 : errorerror: : private field '_enableCoreBindings' is not used [-Werror,-Wunused-private-field]private field '_enableCoreBindings' is not used [-Werror,-Wunused-private-field]

    bool _enableCoreBindings;
    bool _enableCoreBindings;
         ^
         ^
1 error generated.
1 error generated.
make[2]: *** [async_simple/CMakeFiles/async_simple.dir/executors/SimpleExecutor.cpp.o] Error 1
make[2]: *** [async_simple/CMakeFiles/async_simple_static.dir/executors/SimpleExecutor.cpp.o] Error 1
make[1]: *** [async_simple/CMakeFiles/async_simple.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [async_simple/CMakeFiles/async_simple_static.dir/all] Error 2
In file included from /Users/rain/Project/async_simple/demo_example/block_echo_client.cpp:19:
In file included from /Users/rain/Project/async_simple/demo_example/asio_util.hpp:20:
In file included from /Users/rain/Project/async_simple/async_simple/executors/SimpleExecutor.h:23:
/Users/rain/Project/async_simple/async_simple/util/ThreadPool.h:75:10: error: private field '_enableCoreBindings' is not used [-Werror,-Wunused-private-field]
    bool _enableCoreBindings;
         ^
1 error generated.
make[2]: *** [demo_example/CMakeFiles/block_echo_client.dir/block_echo_client.cpp.o] Error 1
make[1]: *** [demo_example/CMakeFiles/block_echo_client.dir/all] Error 2
In file included from /Users/rain/Project/async_simple/demo_example/smtp/smtp_client.cpp:28:
In file included from /Users/rain/Project/async_simple/demo_example/smtp/../asio_util.hpp:20:
In file included from /Users/rain/Project/async_simple/async_simple/executors/SimpleExecutor.h:23:
/Users/rain/Project/async_simple/async_simple/util/ThreadPool.h:75:10: error: private field '_enableCoreBindings' is not used [-Werror,-Wunused-private-field]
    bool _enableCoreBindings;
         ^
1 error generated.
make[2]: *** [demo_example/CMakeFiles/smtp_client.dir/smtp/smtp_client.cpp.o] Error 1
make[1]: *** [demo_example/CMakeFiles/smtp_client.dir/all] Error 2
make: *** [all] Error 2

Reproduction way

$ clang++ --version
Apple clang version 13.0.0 (clang-1300.0.27.3)
Target: x86_64-apple-darwin21.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Anything else

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

We need more benchmarks

Search before asking

  • I searched the issues and found no similar issues.

Why

We need more benchmarks to measure performance for different cases and different components.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

We need benchmarks

Now we lack a benchmark so that we talk about performance by experience only. It is bad. We need benchmark programs and performance CI to make it measurable

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

We have benchmark programs to measure performances.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Add Coroutine SpinLock/Semaphore/Yield

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

the Coroutine SpinLock/Semaphore/Yield also used in Alibaba internal product

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Broken Cmake scripts

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Extract from https://www.reddit.com/r/cpp/comments/ta4h29/async_simple_a_c20_coroutine_library/

- C++20 support was added in 3.12, this project wrongly requires 3.8
- Pulling in dependencies on the main code path for developer requirements (tests, benchmarks)
- Setting user-settable variables (CMAKE_BUILD_TYPE which is also completely ignored by multi-config generators)
- Hardcoding flags (put them in a toolchain/preset)
- Lack of install interface

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

CountChar build failed in gcc 11.2.1

gcc version:
gcc (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

[ 71%] Built target async_simple
[ 85%] Building CXX object demo_example/CMakeFiles/CountChar.dir/CountChar.cpp.o
In file included from /tmp/tmp.XuLZlZqHI1/async_simple/coro/LazyHelper.h:56,
from /tmp/tmp.XuLZlZqHI1/async_simple/coro/Lazy.h:538,
from /tmp/tmp.XuLZlZqHI1/demo_example/CountChar.cpp:20:
/tmp/tmp.XuLZlZqHI1/async_simple/coro/Collect.h: In member function ‘void async_simple::coro::detail::CollectAnyAwaiter<LazyType, IAlloc>::await_suspend(std::__n4861::coroutine_handle)’:
/tmp/tmp.XuLZlZqHI1/async_simple/coro/Collect.h:85:13: error: invalid ‘static_cast’ from type ‘std::__n4861::coroutine_handle’ to type ‘std::__n4861::coroutine_handle<async_simple::coro::detail::LazyPromiseBase>
85 | static_cast<STD_CORO::coroutine_handle>(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86 | &continuation)
| ~~~~~~~~~~~~~~
/tmp/tmp.XuLZlZqHI1/async_simple/coro/Collect.h: In member function ‘void async_simple::coro::detail::CollectAllAwaiter<LazyType, IAlloc, OAlloc, Para>::await_suspend(std::__n4861::coroutine_handle)’:
/tmp/tmp.XuLZlZqHI1/async_simple/coro/Collect.h:161:13: error: invalid ‘static_cast’ from type ‘std::__n4861::coroutine_handle
’ to type ‘std::__n4861::coroutine_handle<async_simple::coro::detail::LazyPromiseBase>
161 | static_cast<STD_CORO::coroutine_handle
>(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
162 | &continuation)
| ~~~~~~~~~~~~~~
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-deprecated-register’ may have been intended to silence earlier diagnostics
gmake[3]: *** [demo_example/CMakeFiles/CountChar.dir/build.make:82: demo_example/CMakeFiles/CountChar.dir/CountChar.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:501: demo_example/CMakeFiles/CountChar.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:508: demo_example/CMakeFiles/CountChar.dir/rule] Error 2
gmake: *** [Makefile:311: CountChar] Error 2

Refactoring IOExecutor

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Current IOExecutor has linux-aio related interface
We hope to remove platform level api at IOExecutor base class, make IOExecutor become empty class
And we can implement UringExecutor, AsioExecutor, and the other user defined IOExecutor based on IOExecutor

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Add CI for Windows

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Given that #84 got merged, the CI for windows should be supported.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Add Mutex/ConditionVariable

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

The coroutine mutex and condition variable already verified in Alibaba product environment, so we hope to export it.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

We need loggers

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

Currently async_simple lacks logger subsystem to log events. Although we don't want async_simple to depend too many things, we should try to make async_simple to depend some loggers conditionally.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.