├── .bazelignore ├── .clang-format ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── bazel.yml │ ├── clang-format.yml │ ├── cmake.yml │ ├── cmake_gcc.yml │ ├── cmake_modules.yml │ ├── conan.yml │ ├── macosx.yml │ ├── static.yml │ └── windows.yml ├── .gitignore ├── BUILD.bazel ├── CMakeLists.txt ├── ChangeLog ├── LICENSE ├── MODULE.bazel ├── NOTICE ├── README.md ├── README_CN.md ├── WORKSPACE.bazel ├── async_simple ├── CMakeLists.txt ├── Collect.h ├── Common.h ├── CommonMacros.h ├── Executor.h ├── Future.h ├── FutureState.h ├── IOExecutor.h ├── LocalState.h ├── MoveWrapper.h ├── Promise.h ├── Signal.h ├── Traits.h ├── Try.h ├── Unit.h ├── async_simple.cppm ├── coro │ ├── Collect.h │ ├── ConditionVariable.h │ ├── CountEvent.h │ ├── DetachedCoroutine.h │ ├── Dispatch.h │ ├── FutureAwaiter.h │ ├── Generator.h │ ├── Latch.h │ ├── Lazy.h │ ├── LazyLocalBase.h │ ├── Mutex.h │ ├── PromiseAllocator.h │ ├── ResumeBySchedule.h │ ├── Semaphore.h │ ├── SharedMutex.h │ ├── Sleep.h │ ├── SpinLock.h │ ├── SyncAwait.h │ ├── Traits.h │ ├── ViaCoroutine.h │ └── test │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── ConditionVariableTest.cpp │ │ ├── DispatchTest.cpp │ │ ├── FutureAwaiterTest.cpp │ │ ├── GeneratorTest.cpp │ │ ├── LatchTest.cpp │ │ ├── LazyLocalTest.cpp │ │ ├── LazyTest.cpp │ │ ├── MutexTest.cpp │ │ ├── PMRLazyTest.cpp │ │ ├── ResumeByScheduleTest.cpp │ │ ├── SemaphoreTest.cpp │ │ ├── SharedMutexTest.cpp │ │ ├── SleepTest.cpp │ │ ├── SpinLockTest.cpp │ │ ├── Time.h │ │ ├── TraitsTest.cpp │ │ └── ViaCoroutineTest.cpp ├── executors │ ├── SimpleExecutor.h │ ├── SimpleIOExecutor.h │ └── test │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ ├── SimpleExecutorTest.cpp │ │ └── SimpleIOExecutorTest.cpp ├── experimental │ └── coroutine.h ├── std.mock.cppm ├── test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── CancellationTest.cpp │ ├── FutureStateTest.cpp │ ├── FutureTest.cpp │ ├── TryTest.cpp │ ├── dotest.cpp │ └── unittest.h ├── uthread │ ├── Async.h │ ├── Await.h │ ├── Collect.h │ ├── Latch.h │ ├── Uthread.h │ ├── internal │ │ ├── Darwin │ │ │ ├── arm64 │ │ │ │ ├── jump_arm64_aapcs_macho_gas.S │ │ │ │ ├── make_arm64_aapcs_macho_gas.S │ │ │ │ └── ontop_arm64_aapcs_macho_gas.S │ │ │ └── x86_64 │ │ │ │ ├── jump_x86_64_sysv_macho_gas.S │ │ │ │ ├── make_x86_64_sysv_macho_gas.S │ │ │ │ └── ontop_x86_64_sysv_macho_gas.S │ │ ├── Linux │ │ │ ├── aarch64 │ │ │ │ ├── jump_arm64_aapcs_elf_gas.S │ │ │ │ ├── make_arm64_aapcs_elf_gas.S │ │ │ │ └── ontop_arm64_aapcs_elf_gas.S │ │ │ ├── ppc64le │ │ │ │ ├── jump_ppc64_sysv_elf_gas.S │ │ │ │ ├── make_ppc64_sysv_elf_gas.S │ │ │ │ └── ontop_ppc64_sysv_elf_gas.S │ │ │ ├── riscv64 │ │ │ │ ├── jump_riscv64_sysv_elf_gas.S │ │ │ │ ├── make_riscv64_sysv_elf_gas.S │ │ │ │ └── ontop_riscv64_sysv_elf_gas.S │ │ │ └── x86_64 │ │ │ │ ├── jump_x86_64_sysv_elf_gas.S │ │ │ │ ├── make_x86_64_sysv_elf_gas.S │ │ │ │ └── ontop_x86_64_sysv_elf_gas.S │ │ ├── thread.cc │ │ ├── thread.h │ │ └── thread_impl.h │ └── test │ │ ├── BUILD.bazel │ │ ├── CMakeLists.txt │ │ └── UthreadTest.cpp └── util │ ├── Condition.h │ ├── Queue.h │ ├── ThreadPool.h │ ├── move_only_function.h │ └── test │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── MoveOnlyFunctionTest.cpp │ └── ThreadPoolTest.cpp ├── bazel ├── config │ ├── BUILD.bazel │ ├── copt.bzl │ └── deps.bzl └── support │ ├── BUILD.bazel │ ├── README.md │ ├── WORKSPACE.bazel │ └── hello.cc ├── benchmarks ├── BUILD.bazel ├── CMakeLists.txt ├── CallDepth.bench.cpp ├── CallDepth.bench.h ├── Future.bench.cpp ├── Future.bench.h ├── Lazy.bench.cpp ├── Lazy.bench.h ├── Mutex.bench.cpp ├── Mutex.bench.h ├── PureSwitch.bench.cpp ├── PureSwitch.bench.h ├── ReadFile.bench.cpp ├── ReadFile.bench.h ├── ReadFileUtil.hpp ├── SharedMutex.bench.cpp ├── SharedMutex.bench.h ├── SpinLock.bench.cpp ├── SpinLock.bench.h ├── ThreadPool.bench.cpp ├── ThreadPool.bench.h ├── Uthread.bench.cpp ├── Uthread.bench.h └── benchmark_main.cpp ├── cmake ├── FindAio.cmake ├── FindBenchmark.cmake ├── FindGTest.cmake └── IsACC.cpp ├── conanfile.py ├── cxx_modules_rules_clang.cmake ├── dbg └── LazyStack.py ├── demo_example ├── BUILD.bazel ├── CMakeLists.txt ├── CountChar.cpp ├── CountCharUsingModules.cpp ├── Input │ ├── 1.txt │ ├── 10.txt │ ├── 2.txt │ ├── 3.txt │ ├── 4.txt │ ├── 5.txt │ ├── 6.txt │ ├── 7.txt │ ├── 8.txt │ ├── 9.txt │ └── file.txt ├── ReadFiles.cpp ├── asio │ ├── COPYING │ ├── LICENSE_1_0.txt │ ├── asio.hpp │ └── asio │ │ ├── any_io_executor.hpp │ │ ├── associated_allocator.hpp │ │ ├── associated_cancellation_slot.hpp │ │ ├── associated_executor.hpp │ │ ├── associator.hpp │ │ ├── async_result.hpp │ │ ├── awaitable.hpp │ │ ├── basic_datagram_socket.hpp │ │ ├── basic_deadline_timer.hpp │ │ ├── basic_file.hpp │ │ ├── basic_io_object.hpp │ │ ├── basic_random_access_file.hpp │ │ ├── basic_raw_socket.hpp │ │ ├── basic_readable_pipe.hpp │ │ ├── basic_seq_packet_socket.hpp │ │ ├── basic_serial_port.hpp │ │ ├── basic_signal_set.hpp │ │ ├── basic_socket.hpp │ │ ├── basic_socket_acceptor.hpp │ │ ├── basic_socket_iostream.hpp │ │ ├── basic_socket_streambuf.hpp │ │ ├── basic_stream_file.hpp │ │ ├── basic_stream_socket.hpp │ │ ├── basic_streambuf.hpp │ │ ├── basic_streambuf_fwd.hpp │ │ ├── basic_waitable_timer.hpp │ │ ├── basic_writable_pipe.hpp │ │ ├── bind_cancellation_slot.hpp │ │ ├── bind_executor.hpp │ │ ├── buffer.hpp │ │ ├── buffer_registration.hpp │ │ ├── buffered_read_stream.hpp │ │ ├── buffered_read_stream_fwd.hpp │ │ ├── buffered_stream.hpp │ │ ├── buffered_stream_fwd.hpp │ │ ├── buffered_write_stream.hpp │ │ ├── buffered_write_stream_fwd.hpp │ │ ├── buffers_iterator.hpp │ │ ├── cancellation_signal.hpp │ │ ├── cancellation_state.hpp │ │ ├── cancellation_type.hpp │ │ ├── co_spawn.hpp │ │ ├── completion_condition.hpp │ │ ├── compose.hpp │ │ ├── connect.hpp │ │ ├── connect_pipe.hpp │ │ ├── coroutine.hpp │ │ ├── deadline_timer.hpp │ │ ├── defer.hpp │ │ ├── detached.hpp │ │ ├── detail │ │ ├── array.hpp │ │ ├── array_fwd.hpp │ │ ├── assert.hpp │ │ ├── atomic_count.hpp │ │ ├── base_from_cancellation_state.hpp │ │ ├── base_from_completion_cond.hpp │ │ ├── bind_handler.hpp │ │ ├── blocking_executor_op.hpp │ │ ├── buffer_resize_guard.hpp │ │ ├── buffer_sequence_adapter.hpp │ │ ├── buffered_stream_storage.hpp │ │ ├── bulk_executor_op.hpp │ │ ├── call_stack.hpp │ │ ├── chrono.hpp │ │ ├── chrono_time_traits.hpp │ │ ├── completion_handler.hpp │ │ ├── concurrency_hint.hpp │ │ ├── conditionally_enabled_event.hpp │ │ ├── conditionally_enabled_mutex.hpp │ │ ├── config.hpp │ │ ├── consuming_buffers.hpp │ │ ├── cstddef.hpp │ │ ├── cstdint.hpp │ │ ├── date_time_fwd.hpp │ │ ├── deadline_timer_service.hpp │ │ ├── dependent_type.hpp │ │ ├── descriptor_ops.hpp │ │ ├── descriptor_read_op.hpp │ │ ├── descriptor_write_op.hpp │ │ ├── dev_poll_reactor.hpp │ │ ├── epoll_reactor.hpp │ │ ├── event.hpp │ │ ├── eventfd_select_interrupter.hpp │ │ ├── executor_function.hpp │ │ ├── executor_op.hpp │ │ ├── fd_set_adapter.hpp │ │ ├── fenced_block.hpp │ │ ├── functional.hpp │ │ ├── future.hpp │ │ ├── gcc_arm_fenced_block.hpp │ │ ├── gcc_hppa_fenced_block.hpp │ │ ├── gcc_sync_fenced_block.hpp │ │ ├── gcc_x86_fenced_block.hpp │ │ ├── global.hpp │ │ ├── handler_alloc_helpers.hpp │ │ ├── handler_cont_helpers.hpp │ │ ├── handler_invoke_helpers.hpp │ │ ├── handler_tracking.hpp │ │ ├── handler_type_requirements.hpp │ │ ├── handler_work.hpp │ │ ├── hash_map.hpp │ │ ├── impl │ │ │ ├── buffer_sequence_adapter.ipp │ │ │ ├── descriptor_ops.ipp │ │ │ ├── dev_poll_reactor.hpp │ │ │ ├── dev_poll_reactor.ipp │ │ │ ├── epoll_reactor.hpp │ │ │ ├── epoll_reactor.ipp │ │ │ ├── eventfd_select_interrupter.ipp │ │ │ ├── handler_tracking.ipp │ │ │ ├── io_uring_descriptor_service.ipp │ │ │ ├── io_uring_file_service.ipp │ │ │ ├── io_uring_service.hpp │ │ │ ├── io_uring_service.ipp │ │ │ ├── io_uring_socket_service_base.ipp │ │ │ ├── kqueue_reactor.hpp │ │ │ ├── kqueue_reactor.ipp │ │ │ ├── null_event.ipp │ │ │ ├── pipe_select_interrupter.ipp │ │ │ ├── posix_event.ipp │ │ │ ├── posix_mutex.ipp │ │ │ ├── posix_serial_port_service.ipp │ │ │ ├── posix_thread.ipp │ │ │ ├── posix_tss_ptr.ipp │ │ │ ├── reactive_descriptor_service.ipp │ │ │ ├── reactive_socket_service_base.ipp │ │ │ ├── resolver_service_base.ipp │ │ │ ├── scheduler.ipp │ │ │ ├── select_reactor.hpp │ │ │ ├── select_reactor.ipp │ │ │ ├── service_registry.hpp │ │ │ ├── service_registry.ipp │ │ │ ├── signal_set_service.ipp │ │ │ ├── socket_ops.ipp │ │ │ ├── socket_select_interrupter.ipp │ │ │ ├── strand_executor_service.hpp │ │ │ ├── strand_executor_service.ipp │ │ │ ├── strand_service.hpp │ │ │ ├── strand_service.ipp │ │ │ ├── thread_context.ipp │ │ │ ├── throw_error.ipp │ │ │ ├── timer_queue_ptime.ipp │ │ │ ├── timer_queue_set.ipp │ │ │ ├── win_event.ipp │ │ │ ├── win_iocp_file_service.ipp │ │ │ ├── win_iocp_handle_service.ipp │ │ │ ├── win_iocp_io_context.hpp │ │ │ ├── win_iocp_io_context.ipp │ │ │ ├── win_iocp_serial_port_service.ipp │ │ │ ├── win_iocp_socket_service_base.ipp │ │ │ ├── win_mutex.ipp │ │ │ ├── win_object_handle_service.ipp │ │ │ ├── win_static_mutex.ipp │ │ │ ├── win_thread.ipp │ │ │ ├── win_tss_ptr.ipp │ │ │ ├── winrt_ssocket_service_base.ipp │ │ │ ├── winrt_timer_scheduler.hpp │ │ │ ├── winrt_timer_scheduler.ipp │ │ │ └── winsock_init.ipp │ │ ├── io_control.hpp │ │ ├── io_object_impl.hpp │ │ ├── io_uring_descriptor_read_at_op.hpp │ │ ├── io_uring_descriptor_read_op.hpp │ │ ├── io_uring_descriptor_service.hpp │ │ ├── io_uring_descriptor_write_at_op.hpp │ │ ├── io_uring_descriptor_write_op.hpp │ │ ├── io_uring_file_service.hpp │ │ ├── io_uring_null_buffers_op.hpp │ │ ├── io_uring_operation.hpp │ │ ├── io_uring_service.hpp │ │ ├── io_uring_socket_accept_op.hpp │ │ ├── io_uring_socket_connect_op.hpp │ │ ├── io_uring_socket_recv_op.hpp │ │ ├── io_uring_socket_recvfrom_op.hpp │ │ ├── io_uring_socket_recvmsg_op.hpp │ │ ├── io_uring_socket_send_op.hpp │ │ ├── io_uring_socket_sendto_op.hpp │ │ ├── io_uring_socket_service.hpp │ │ ├── io_uring_socket_service_base.hpp │ │ ├── io_uring_wait_op.hpp │ │ ├── is_buffer_sequence.hpp │ │ ├── is_executor.hpp │ │ ├── keyword_tss_ptr.hpp │ │ ├── kqueue_reactor.hpp │ │ ├── limits.hpp │ │ ├── local_free_on_block_exit.hpp │ │ ├── macos_fenced_block.hpp │ │ ├── memory.hpp │ │ ├── mutex.hpp │ │ ├── non_const_lvalue.hpp │ │ ├── noncopyable.hpp │ │ ├── null_event.hpp │ │ ├── null_fenced_block.hpp │ │ ├── null_global.hpp │ │ ├── null_mutex.hpp │ │ ├── null_reactor.hpp │ │ ├── null_signal_blocker.hpp │ │ ├── null_socket_service.hpp │ │ ├── null_static_mutex.hpp │ │ ├── null_thread.hpp │ │ ├── null_tss_ptr.hpp │ │ ├── object_pool.hpp │ │ ├── old_win_sdk_compat.hpp │ │ ├── op_queue.hpp │ │ ├── operation.hpp │ │ ├── pipe_select_interrupter.hpp │ │ ├── pop_options.hpp │ │ ├── posix_event.hpp │ │ ├── posix_fd_set_adapter.hpp │ │ ├── posix_global.hpp │ │ ├── posix_mutex.hpp │ │ ├── posix_serial_port_service.hpp │ │ ├── posix_signal_blocker.hpp │ │ ├── posix_static_mutex.hpp │ │ ├── posix_thread.hpp │ │ ├── posix_tss_ptr.hpp │ │ ├── push_options.hpp │ │ ├── reactive_descriptor_service.hpp │ │ ├── reactive_null_buffers_op.hpp │ │ ├── reactive_socket_accept_op.hpp │ │ ├── reactive_socket_connect_op.hpp │ │ ├── reactive_socket_recv_op.hpp │ │ ├── reactive_socket_recvfrom_op.hpp │ │ ├── reactive_socket_recvmsg_op.hpp │ │ ├── reactive_socket_send_op.hpp │ │ ├── reactive_socket_sendto_op.hpp │ │ ├── reactive_socket_service.hpp │ │ ├── reactive_socket_service_base.hpp │ │ ├── reactive_wait_op.hpp │ │ ├── reactor.hpp │ │ ├── reactor_op.hpp │ │ ├── reactor_op_queue.hpp │ │ ├── recycling_allocator.hpp │ │ ├── regex_fwd.hpp │ │ ├── resolve_endpoint_op.hpp │ │ ├── resolve_op.hpp │ │ ├── resolve_query_op.hpp │ │ ├── resolver_service.hpp │ │ ├── resolver_service_base.hpp │ │ ├── scheduler.hpp │ │ ├── scheduler_operation.hpp │ │ ├── scheduler_task.hpp │ │ ├── scheduler_thread_info.hpp │ │ ├── scoped_lock.hpp │ │ ├── scoped_ptr.hpp │ │ ├── select_interrupter.hpp │ │ ├── select_reactor.hpp │ │ ├── service_registry.hpp │ │ ├── signal_blocker.hpp │ │ ├── signal_handler.hpp │ │ ├── signal_init.hpp │ │ ├── signal_op.hpp │ │ ├── signal_set_service.hpp │ │ ├── socket_holder.hpp │ │ ├── socket_ops.hpp │ │ ├── socket_option.hpp │ │ ├── socket_select_interrupter.hpp │ │ ├── socket_types.hpp │ │ ├── solaris_fenced_block.hpp │ │ ├── source_location.hpp │ │ ├── static_mutex.hpp │ │ ├── std_event.hpp │ │ ├── std_fenced_block.hpp │ │ ├── std_global.hpp │ │ ├── std_mutex.hpp │ │ ├── std_static_mutex.hpp │ │ ├── std_thread.hpp │ │ ├── strand_executor_service.hpp │ │ ├── strand_service.hpp │ │ ├── string_view.hpp │ │ ├── thread.hpp │ │ ├── thread_context.hpp │ │ ├── thread_group.hpp │ │ ├── thread_info_base.hpp │ │ ├── throw_error.hpp │ │ ├── throw_exception.hpp │ │ ├── timer_queue.hpp │ │ ├── timer_queue_base.hpp │ │ ├── timer_queue_ptime.hpp │ │ ├── timer_queue_set.hpp │ │ ├── timer_scheduler.hpp │ │ ├── timer_scheduler_fwd.hpp │ │ ├── tss_ptr.hpp │ │ ├── type_traits.hpp │ │ ├── variadic_templates.hpp │ │ ├── wait_handler.hpp │ │ ├── wait_op.hpp │ │ ├── win_event.hpp │ │ ├── win_fd_set_adapter.hpp │ │ ├── win_fenced_block.hpp │ │ ├── win_global.hpp │ │ ├── win_iocp_file_service.hpp │ │ ├── win_iocp_handle_read_op.hpp │ │ ├── win_iocp_handle_service.hpp │ │ ├── win_iocp_handle_write_op.hpp │ │ ├── win_iocp_io_context.hpp │ │ ├── win_iocp_null_buffers_op.hpp │ │ ├── win_iocp_operation.hpp │ │ ├── win_iocp_overlapped_op.hpp │ │ ├── win_iocp_overlapped_ptr.hpp │ │ ├── win_iocp_serial_port_service.hpp │ │ ├── win_iocp_socket_accept_op.hpp │ │ ├── win_iocp_socket_connect_op.hpp │ │ ├── win_iocp_socket_recv_op.hpp │ │ ├── win_iocp_socket_recvfrom_op.hpp │ │ ├── win_iocp_socket_recvmsg_op.hpp │ │ ├── win_iocp_socket_send_op.hpp │ │ ├── win_iocp_socket_service.hpp │ │ ├── win_iocp_socket_service_base.hpp │ │ ├── win_iocp_thread_info.hpp │ │ ├── win_iocp_wait_op.hpp │ │ ├── win_mutex.hpp │ │ ├── win_object_handle_service.hpp │ │ ├── win_static_mutex.hpp │ │ ├── win_thread.hpp │ │ ├── win_tss_ptr.hpp │ │ ├── winapp_thread.hpp │ │ ├── wince_thread.hpp │ │ ├── winrt_async_manager.hpp │ │ ├── winrt_async_op.hpp │ │ ├── winrt_resolve_op.hpp │ │ ├── winrt_resolver_service.hpp │ │ ├── winrt_socket_connect_op.hpp │ │ ├── winrt_socket_recv_op.hpp │ │ ├── winrt_socket_send_op.hpp │ │ ├── winrt_ssocket_service.hpp │ │ ├── winrt_ssocket_service_base.hpp │ │ ├── winrt_timer_scheduler.hpp │ │ ├── winrt_utils.hpp │ │ ├── winsock_init.hpp │ │ ├── work_dispatcher.hpp │ │ └── wrapped_handler.hpp │ │ ├── dispatch.hpp │ │ ├── error.hpp │ │ ├── error_code.hpp │ │ ├── execution.hpp │ │ ├── execution │ │ ├── allocator.hpp │ │ ├── any_executor.hpp │ │ ├── bad_executor.hpp │ │ ├── blocking.hpp │ │ ├── blocking_adaptation.hpp │ │ ├── bulk_execute.hpp │ │ ├── bulk_guarantee.hpp │ │ ├── connect.hpp │ │ ├── context.hpp │ │ ├── context_as.hpp │ │ ├── detail │ │ │ ├── as_invocable.hpp │ │ │ ├── as_operation.hpp │ │ │ ├── as_receiver.hpp │ │ │ ├── bulk_sender.hpp │ │ │ ├── submit_receiver.hpp │ │ │ └── void_receiver.hpp │ │ ├── execute.hpp │ │ ├── executor.hpp │ │ ├── impl │ │ │ ├── bad_executor.ipp │ │ │ └── receiver_invocation_error.ipp │ │ ├── invocable_archetype.hpp │ │ ├── mapping.hpp │ │ ├── occupancy.hpp │ │ ├── operation_state.hpp │ │ ├── outstanding_work.hpp │ │ ├── prefer_only.hpp │ │ ├── receiver.hpp │ │ ├── receiver_invocation_error.hpp │ │ ├── relationship.hpp │ │ ├── schedule.hpp │ │ ├── scheduler.hpp │ │ ├── sender.hpp │ │ ├── set_done.hpp │ │ ├── set_error.hpp │ │ ├── set_value.hpp │ │ ├── start.hpp │ │ └── submit.hpp │ │ ├── execution_context.hpp │ │ ├── executor.hpp │ │ ├── executor_work_guard.hpp │ │ ├── experimental │ │ ├── append.hpp │ │ ├── as_single.hpp │ │ ├── as_tuple.hpp │ │ ├── awaitable_operators.hpp │ │ ├── basic_channel.hpp │ │ ├── basic_concurrent_channel.hpp │ │ ├── cancellation_condition.hpp │ │ ├── channel.hpp │ │ ├── channel_error.hpp │ │ ├── channel_traits.hpp │ │ ├── co_spawn.hpp │ │ ├── concurrent_channel.hpp │ │ ├── coro.hpp │ │ ├── coro_traits.hpp │ │ ├── deferred.hpp │ │ ├── detail │ │ │ ├── channel_handler.hpp │ │ │ ├── channel_message.hpp │ │ │ ├── channel_operation.hpp │ │ │ ├── channel_payload.hpp │ │ │ ├── channel_receive_op.hpp │ │ │ ├── channel_send_functions.hpp │ │ │ ├── channel_send_op.hpp │ │ │ ├── channel_service.hpp │ │ │ ├── completion_handler_erasure.hpp │ │ │ ├── coro_promise_allocator.hpp │ │ │ ├── has_signature.hpp │ │ │ ├── impl │ │ │ │ └── channel_service.hpp │ │ │ └── partial_promise.hpp │ │ ├── impl │ │ │ ├── append.hpp │ │ │ ├── as_single.hpp │ │ │ ├── as_tuple.hpp │ │ │ ├── channel_error.ipp │ │ │ ├── coro.hpp │ │ │ ├── deferred.hpp │ │ │ ├── parallel_group.hpp │ │ │ ├── prepend.hpp │ │ │ ├── promise.hpp │ │ │ └── use_coro.hpp │ │ ├── parallel_group.hpp │ │ ├── prepend.hpp │ │ ├── promise.hpp │ │ └── use_coro.hpp │ │ ├── file_base.hpp │ │ ├── generic │ │ ├── basic_endpoint.hpp │ │ ├── datagram_protocol.hpp │ │ ├── detail │ │ │ ├── endpoint.hpp │ │ │ └── impl │ │ │ │ └── endpoint.ipp │ │ ├── raw_protocol.hpp │ │ ├── seq_packet_protocol.hpp │ │ └── stream_protocol.hpp │ │ ├── handler_alloc_hook.hpp │ │ ├── handler_continuation_hook.hpp │ │ ├── handler_invoke_hook.hpp │ │ ├── high_resolution_timer.hpp │ │ ├── impl │ │ ├── any_io_executor.ipp │ │ ├── awaitable.hpp │ │ ├── buffered_read_stream.hpp │ │ ├── buffered_write_stream.hpp │ │ ├── cancellation_signal.ipp │ │ ├── co_spawn.hpp │ │ ├── compose.hpp │ │ ├── connect.hpp │ │ ├── connect_pipe.hpp │ │ ├── connect_pipe.ipp │ │ ├── defer.hpp │ │ ├── detached.hpp │ │ ├── dispatch.hpp │ │ ├── error.ipp │ │ ├── error_code.ipp │ │ ├── execution_context.hpp │ │ ├── execution_context.ipp │ │ ├── executor.hpp │ │ ├── executor.ipp │ │ ├── handler_alloc_hook.ipp │ │ ├── io_context.hpp │ │ ├── io_context.ipp │ │ ├── multiple_exceptions.ipp │ │ ├── post.hpp │ │ ├── read.hpp │ │ ├── read_at.hpp │ │ ├── read_until.hpp │ │ ├── redirect_error.hpp │ │ ├── serial_port_base.hpp │ │ ├── serial_port_base.ipp │ │ ├── spawn.hpp │ │ ├── src.hpp │ │ ├── system_context.hpp │ │ ├── system_context.ipp │ │ ├── system_executor.hpp │ │ ├── thread_pool.hpp │ │ ├── thread_pool.ipp │ │ ├── use_awaitable.hpp │ │ ├── use_future.hpp │ │ ├── write.hpp │ │ └── write_at.hpp │ │ ├── io_context.hpp │ │ ├── io_context_strand.hpp │ │ ├── io_service.hpp │ │ ├── io_service_strand.hpp │ │ ├── ip │ │ ├── address.hpp │ │ ├── address_v4.hpp │ │ ├── address_v4_iterator.hpp │ │ ├── address_v4_range.hpp │ │ ├── address_v6.hpp │ │ ├── address_v6_iterator.hpp │ │ ├── address_v6_range.hpp │ │ ├── bad_address_cast.hpp │ │ ├── basic_endpoint.hpp │ │ ├── basic_resolver.hpp │ │ ├── basic_resolver_entry.hpp │ │ ├── basic_resolver_iterator.hpp │ │ ├── basic_resolver_query.hpp │ │ ├── basic_resolver_results.hpp │ │ ├── detail │ │ │ ├── endpoint.hpp │ │ │ ├── impl │ │ │ │ └── endpoint.ipp │ │ │ └── socket_option.hpp │ │ ├── host_name.hpp │ │ ├── icmp.hpp │ │ ├── impl │ │ │ ├── address.hpp │ │ │ ├── address.ipp │ │ │ ├── address_v4.hpp │ │ │ ├── address_v4.ipp │ │ │ ├── address_v6.hpp │ │ │ ├── address_v6.ipp │ │ │ ├── basic_endpoint.hpp │ │ │ ├── host_name.ipp │ │ │ ├── network_v4.hpp │ │ │ ├── network_v4.ipp │ │ │ ├── network_v6.hpp │ │ │ └── network_v6.ipp │ │ ├── multicast.hpp │ │ ├── network_v4.hpp │ │ ├── network_v6.hpp │ │ ├── resolver_base.hpp │ │ ├── resolver_query_base.hpp │ │ ├── tcp.hpp │ │ ├── udp.hpp │ │ ├── unicast.hpp │ │ └── v6_only.hpp │ │ ├── is_applicable_property.hpp │ │ ├── is_executor.hpp │ │ ├── is_read_buffered.hpp │ │ ├── is_write_buffered.hpp │ │ ├── local │ │ ├── basic_endpoint.hpp │ │ ├── connect_pair.hpp │ │ ├── datagram_protocol.hpp │ │ ├── detail │ │ │ ├── endpoint.hpp │ │ │ └── impl │ │ │ │ └── endpoint.ipp │ │ └── stream_protocol.hpp │ │ ├── multiple_exceptions.hpp │ │ ├── packaged_task.hpp │ │ ├── placeholders.hpp │ │ ├── posix │ │ ├── basic_descriptor.hpp │ │ ├── basic_stream_descriptor.hpp │ │ ├── descriptor.hpp │ │ ├── descriptor_base.hpp │ │ └── stream_descriptor.hpp │ │ ├── post.hpp │ │ ├── prefer.hpp │ │ ├── query.hpp │ │ ├── random_access_file.hpp │ │ ├── read.hpp │ │ ├── read_at.hpp │ │ ├── read_until.hpp │ │ ├── readable_pipe.hpp │ │ ├── redirect_error.hpp │ │ ├── registered_buffer.hpp │ │ ├── require.hpp │ │ ├── require_concept.hpp │ │ ├── serial_port.hpp │ │ ├── serial_port_base.hpp │ │ ├── signal_set.hpp │ │ ├── socket_base.hpp │ │ ├── spawn.hpp │ │ ├── ssl.hpp │ │ ├── ssl │ │ ├── context.hpp │ │ ├── context_base.hpp │ │ ├── detail │ │ │ ├── buffered_handshake_op.hpp │ │ │ ├── engine.hpp │ │ │ ├── handshake_op.hpp │ │ │ ├── impl │ │ │ │ ├── engine.ipp │ │ │ │ └── openssl_init.ipp │ │ │ ├── io.hpp │ │ │ ├── openssl_init.hpp │ │ │ ├── openssl_types.hpp │ │ │ ├── password_callback.hpp │ │ │ ├── read_op.hpp │ │ │ ├── shutdown_op.hpp │ │ │ ├── stream_core.hpp │ │ │ ├── verify_callback.hpp │ │ │ └── write_op.hpp │ │ ├── error.hpp │ │ ├── host_name_verification.hpp │ │ ├── impl │ │ │ ├── context.hpp │ │ │ ├── context.ipp │ │ │ ├── error.ipp │ │ │ ├── host_name_verification.ipp │ │ │ ├── rfc2818_verification.ipp │ │ │ └── src.hpp │ │ ├── rfc2818_verification.hpp │ │ ├── stream.hpp │ │ ├── stream_base.hpp │ │ ├── verify_context.hpp │ │ └── verify_mode.hpp │ │ ├── static_thread_pool.hpp │ │ ├── steady_timer.hpp │ │ ├── strand.hpp │ │ ├── stream_file.hpp │ │ ├── streambuf.hpp │ │ ├── system_context.hpp │ │ ├── system_error.hpp │ │ ├── system_executor.hpp │ │ ├── system_timer.hpp │ │ ├── this_coro.hpp │ │ ├── thread.hpp │ │ ├── thread_pool.hpp │ │ ├── time_traits.hpp │ │ ├── traits │ │ ├── bulk_execute_free.hpp │ │ ├── bulk_execute_member.hpp │ │ ├── connect_free.hpp │ │ ├── connect_member.hpp │ │ ├── equality_comparable.hpp │ │ ├── execute_free.hpp │ │ ├── execute_member.hpp │ │ ├── prefer_free.hpp │ │ ├── prefer_member.hpp │ │ ├── query_free.hpp │ │ ├── query_member.hpp │ │ ├── query_static_constexpr_member.hpp │ │ ├── require_concept_free.hpp │ │ ├── require_concept_member.hpp │ │ ├── require_free.hpp │ │ ├── require_member.hpp │ │ ├── schedule_free.hpp │ │ ├── schedule_member.hpp │ │ ├── set_done_free.hpp │ │ ├── set_done_member.hpp │ │ ├── set_error_free.hpp │ │ ├── set_error_member.hpp │ │ ├── set_value_free.hpp │ │ ├── set_value_member.hpp │ │ ├── start_free.hpp │ │ ├── start_member.hpp │ │ ├── static_query.hpp │ │ ├── static_require.hpp │ │ ├── static_require_concept.hpp │ │ ├── submit_free.hpp │ │ └── submit_member.hpp │ │ ├── ts │ │ ├── buffer.hpp │ │ ├── executor.hpp │ │ ├── internet.hpp │ │ ├── io_context.hpp │ │ ├── net.hpp │ │ ├── netfwd.hpp │ │ ├── socket.hpp │ │ └── timer.hpp │ │ ├── unyield.hpp │ │ ├── use_awaitable.hpp │ │ ├── use_future.hpp │ │ ├── uses_executor.hpp │ │ ├── version.hpp │ │ ├── wait_traits.hpp │ │ ├── windows │ │ ├── basic_object_handle.hpp │ │ ├── basic_overlapped_handle.hpp │ │ ├── basic_random_access_handle.hpp │ │ ├── basic_stream_handle.hpp │ │ ├── object_handle.hpp │ │ ├── overlapped_handle.hpp │ │ ├── overlapped_ptr.hpp │ │ ├── random_access_handle.hpp │ │ └── stream_handle.hpp │ │ ├── writable_pipe.hpp │ │ ├── write.hpp │ │ ├── write_at.hpp │ │ └── yield.hpp ├── asio_coro_util.hpp ├── asio_util.hpp ├── async_echo_client.cpp ├── async_echo_server.cpp ├── async_multiple_core_echo_server.cpp ├── block_echo_client.cpp ├── block_echo_server.cpp ├── http │ ├── block_http │ │ ├── block_connection.hpp │ │ └── block_http_server.cpp │ ├── coroutine_http │ │ ├── connection.hpp │ │ ├── http_client.cpp │ │ ├── http_server.cpp │ │ └── multiple_core_http_server.cpp │ ├── http_request.hpp │ ├── http_response.hpp │ └── index.html ├── io_context_pool.hpp ├── pmr_lazy.cpp └── smtp │ ├── smtp_client.cpp │ └── test_file.txt ├── docker ├── centos7 │ └── Dockerfile ├── rockylinux │ └── Dockerfile └── ubuntu │ └── Dockerfile ├── docs ├── .vitepress │ └── config.ts ├── docs.cn │ ├── ConditionVariable.md │ ├── Executor.md │ ├── Future.md │ ├── GetStarted.md │ ├── HybridCoro.md │ ├── Latch.md │ ├── Lazy.md │ ├── Lock.md │ ├── Performance.md │ ├── Semaphore.md │ ├── Try.md │ ├── Uthread.md │ ├── dispatch.md │ ├── hybrid_coro_example.png │ ├── images │ │ ├── call_depth.png │ │ ├── call_depth_mem.png │ │ ├── call_depth_noexcept.png │ │ ├── pure_switch.png │ │ ├── read_diff_size.png │ │ ├── same_read.png │ │ └── vs.png │ ├── 与无栈协程交互.md │ ├── 信号与任务的取消.md │ ├── 协程与异步风格比较.md │ ├── 基于async_simple的协程性能定量分析.md │ ├── 无栈协程.md │ ├── 用 async_simple 改造网络库.md │ └── 调试 Lazy.md ├── docs.en │ ├── ConditionVariable.md │ ├── DebuggingLazy.md │ ├── Executor.md │ ├── Future.md │ ├── GetStarted.md │ ├── HowToFixIssue.md │ ├── HybridCoro.md │ ├── ImproveNetLibWithAsyncSimple.md │ ├── InteractingWithStacklessCoroutine.md │ ├── Latch.md │ ├── Lazy.md │ ├── Lock.md │ ├── Performance.md │ ├── QuantitativeAnalysisReportOfCoroutinePerformance.md │ ├── Semaphore.md │ ├── SignalAndCancellation.md │ ├── StacklessCoroutine.md │ ├── StacklessCoroutineAndFuture.md │ ├── Try.md │ ├── Uthread.md │ ├── dispatch.md │ ├── hybrid_coro_example.png │ ├── images │ │ ├── call_depth.png │ │ ├── call_depth_mem.png │ │ ├── call_depth_noexcept.png │ │ ├── pure_switch.png │ │ ├── read_diff_size.png │ │ ├── same_read.png │ │ └── vs.png │ └── modules-converter.md └── index.md ├── package.json └── xmake.lua /.bazelignore: -------------------------------------------------------------------------------- 1 | bazel/support 2 | build 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Search before asking 2 | 3 | - [ ] I searched the [issues](https://github.com/alibaba/async_simple/issues) and found no similar issues. 4 | 5 | 6 | ### What happened + What you expected to happen 7 | 8 | 9 | ### Reproduction way 10 | 11 | 12 | ### Anything else 13 | 14 | 15 | ### Are you willing to submit a PR? 16 | 17 | - [ ] Yes I am willing to submit a PR! 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Why 4 | 5 | 6 | 7 | 8 | 9 | ## What is changing 10 | 11 | ## Example 12 | 13 | 14 | -------------------------------------------------------------------------------- /.github/workflows/bazel.yml: -------------------------------------------------------------------------------- 1 | name: Bazel 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-22.04 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | 16 | - name: deps 17 | # Install Bazel See: https://bazel.build/install/ubuntu 18 | run: | 19 | sudo apt install -y libaio-dev 20 | - name: Build 21 | # Build your program with clang 22 | working-directory: ${{github.workspace}} 23 | # Hacking due to there is a bug in either clang14 or libstdc++13 that the compiler is 24 | # complaining a consteval function is not constant expression. 25 | run: bazel build --action_env=CXX=clang++ --action_env=CC=clang --cxxopt="-Dconsteval=constexpr" ... 26 | 27 | - name: Test 28 | # Build and Execute tests 29 | working-directory: ${{github.workspace}} 30 | # Hacking due to there is a bug in either clang14 or libstdc++13 that the compiler is 31 | # complaining a consteval function is not constant expression. 32 | run: bazel test --action_env=CXX=clang++ --action_env=CC=clang --test_output=errors --cxxopt="-Dconsteval=constexpr" ... 33 | -------------------------------------------------------------------------------- /.github/workflows/clang-format.yml: -------------------------------------------------------------------------------- 1 | name: Clang Format Diff 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-22.04 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | with: 17 | fetch-depth: 0 18 | - name: install clang-format 19 | run: | 20 | sudo apt install -y clang-format 21 | clang-format --version 22 | - name: check-diff 23 | run: | 24 | diff=`git-clang-format --diff HEAD^` 25 | if ! [[ "$diff" = "no modified files to format" || "$diff" = "clang-format did not modify any files" ]]; then 26 | echo "The diff you sent is not formatted correctly." 27 | echo "The suggested format is" 28 | echo "$diff" 29 | exit 1 30 | fi 31 | -------------------------------------------------------------------------------- /.github/workflows/macosx.yml: -------------------------------------------------------------------------------- 1 | name: macosx 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | env: 10 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 11 | BUILD_TYPE: Release 12 | 13 | jobs: 14 | build_with_bazel: 15 | runs-on: macos-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | 20 | - name: Build 21 | # Build all program 22 | working-directory: ${{github.workspace}} 23 | run: bazel build --define=ASYNC_SIMPLE_DISABLE_AIO=true ... 24 | 25 | - name: Test 26 | # Execute tests 27 | working-directory: ${{github.workspace}} 28 | run: bazel test --define=ASYNC_SIMPLE_DISABLE_AIO=true --test_output=errors ... 29 | build_with_cmake: 30 | runs-on: macos-latest 31 | 32 | steps: 33 | - uses: actions/checkout@v2 34 | 35 | - name: deps 36 | run: brew install googletest 37 | - name: Configure CMake 38 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 39 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 40 | run: CXX=clang++ CC=clang cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 41 | - name: Build 42 | # Build your program with the given configuration 43 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --verbose -j 44 | 45 | - name: Test 46 | # Execute tests defined by the CMake configuration. 47 | working-directory: ${{github.workspace}}/build 48 | run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure 49 | -------------------------------------------------------------------------------- /.github/workflows/static.yml: -------------------------------------------------------------------------------- 1 | # Simple workflow for deploying static content to GitHub Pages 2 | name: Deploy static content to Pages 3 | 4 | on: 5 | # Runs on pushes targeting the default branch 6 | push: 7 | branches: ["main"] 8 | 9 | # Allows you to run this workflow manually from the Actions tab 10 | workflow_dispatch: 11 | 12 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 13 | permissions: 14 | contents: read 15 | pages: write 16 | id-token: write 17 | 18 | # Allow one concurrent deployment 19 | concurrency: 20 | group: "pages" 21 | cancel-in-progress: true 22 | 23 | jobs: 24 | # Single deploy job since we're just deploying 25 | deploy: 26 | environment: 27 | name: github-pages 28 | url: ${{ steps.deployment.outputs.page_url }} 29 | runs-on: ubuntu-22.04 30 | steps: 31 | - name: Install 32 | run: sudo apt-get install doxygen graphviz 33 | - name: Checkout 34 | uses: actions/checkout@v3 35 | - name: Setup Pages 36 | uses: actions/configure-pages@v3 37 | - name: Yarn Install 38 | run: yarn install 39 | working-directory: ${{github.workspace}} 40 | - name: Build Website 41 | run: yarn docs:build 42 | working-directory: ${{github.workspace}} 43 | - name: Upload artifact 44 | uses: actions/upload-pages-artifact@v1 45 | with: 46 | # Upload entire repository 47 | path: 'docs/public' 48 | - name: Deploy to GitHub Pages 49 | id: deployment 50 | uses: actions/deploy-pages@v1 51 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: Windows 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | env: 10 | # Customize the CMake build type here (Release, Debug, etc.) 11 | BUILD_TYPE: Release 12 | 13 | jobs: 14 | build_with_cmake: 15 | runs-on: windows-2019 16 | 17 | strategy: 18 | matrix: 19 | mode: [ Release ] 20 | arch: [ x86 ] 21 | 22 | env: 23 | CXX: cl.exe 24 | CC: cl.exe 25 | 26 | steps: 27 | - uses: actions/checkout@v2 28 | 29 | - name: Generate Project 30 | run: cmake -B Build/${{ matrix.mode }} -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DRFK_DEV=1 -G "Visual Studio 16 2019" -A x64 31 | 32 | - name: Build async_simple 33 | run: cmake --build Build/${{ matrix.mode }} --config ${{ matrix.mode }} --verbose 34 | 35 | - name: Test 36 | working-directory: ${{github.workspace}}/Build/${{ matrix.mode }} 37 | # Execute tests defined by the CMake configuration. 38 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 39 | run: ctest -C ${{ matrix.mode }} --output-on-failure 40 | 41 | build_with_bazel: 42 | runs-on: windows-2019 43 | 44 | steps: 45 | - uses: actions/checkout@v2 46 | 47 | - name: Build 48 | working-directory: ${{github.workspace}} 49 | run: bazel build ... 50 | 51 | - name: Test 52 | working-directory: ${{github.workspace}} 53 | run: bazel test --test_output=errors ... 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.os 3 | *~ 4 | build_options.* 5 | \.* 6 | config.log 7 | *.o 8 | build/ 9 | build*/ 10 | _external/ 11 | core.* 12 | \#*\# 13 | !.github 14 | !.gitignore 15 | !.clang-format 16 | *.so 17 | *.a 18 | vgcore.* 19 | indexlib/config.h 20 | indexlib/config.cpp 21 | data 22 | testdata/*Test/ 23 | testdata/*TestE/ 24 | error_log_collector.log 25 | coro_trace.log 26 | *.log 27 | test.h 28 | bazel-* 29 | !.bazelignore 30 | !.bazelrc 31 | cmake-build-debug 32 | !docs/.vitepress 33 | docs/.vitepress/cache 34 | docs/public 35 | node_modules 36 | compile_commands.json 37 | 38 | # Ignore Bzlmod lock file until it is more stable 39 | MODULE.bazel.lock 40 | -------------------------------------------------------------------------------- /MODULE.bazel: -------------------------------------------------------------------------------- 1 | module(name = "com_github_async_simple") 2 | bazel_dep(name = "platforms", version = "0.0.10") 3 | bazel_dep(name = "bazel_skylib", version = "1.7.1") 4 | bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest", dev_dependency = True) 5 | bazel_dep(name = "google_benchmark", version = "1.8.5", repo_name = "com_google_benchmark", dev_dependency = True) 6 | bazel_dep(name = "boringssl", version = "0.20250311.0", dev_dependency = True) 7 | 8 | # Hedron's Compile Commands Extractor for Bazel 9 | # https://github.com/hedronvision/bazel-compile-commands-extractor 10 | bazel_dep(name = "hedron_compile_commands", dev_dependency = True) 11 | git_override( 12 | module_name = "hedron_compile_commands", 13 | remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git", 14 | commit = "1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93", 15 | ) 16 | -------------------------------------------------------------------------------- /WORKSPACE.bazel: -------------------------------------------------------------------------------- 1 | workspace(name = "com_github_async_simple") 2 | 3 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4 | load("//bazel/config:deps.bzl", "async_simple_dependencies") 5 | async_simple_dependencies() 6 | 7 | http_archive( 8 | name = "rules_python", 9 | sha256 = "e5470e92a18aa51830db99a4d9c492cc613761d5bdb7131c04bd92b9834380f6", 10 | strip_prefix = "rules_python-4b84ad270387a7c439ebdccfd530e2339601ef27", 11 | urls = [ 12 | "https://mirror.bazel.build/github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz", 13 | "https://github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz", 14 | ], 15 | ) 16 | 17 | http_archive( 18 | name = "com_google_googletest", # 2021-07-09 19 | sha256 = "353571c2440176ded91c2de6d6cd88ddd41401d14692ec1f99e35d013feda55a", 20 | strip_prefix = "googletest-release-1.11.0", 21 | urls = ["https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip"], 22 | ) 23 | 24 | http_archive( 25 | name = "com_google_benchmark", # 2022-07-25 26 | sha256 = "e0e6a0f2a5e8971198e5d382507bfe8e4be504797d75bb7aec44b5ea368fa100", 27 | strip_prefix = "benchmark-1.7.0", 28 | urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.7.0.zip"], 29 | ) 30 | 31 | http_archive( 32 | name = "boringssl", 33 | sha256 = "5d299325d1db8b2f2db3d927c7bc1f9fcbd05a3f9b5c8239fa527c09bf97f995", # Last updated 2022-10-19 34 | strip_prefix = "boringssl-0acfcff4be10514aacb98eb8ab27bb60136d131b", 35 | urls = ["https://github.com/google/boringssl/archive/0acfcff4be10514aacb98eb8ab27bb60136d131b.tar.gz"], 36 | ) 37 | -------------------------------------------------------------------------------- /async_simple/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef ASYNC_SIMPLE_COMMON_H 17 | #define ASYNC_SIMPLE_COMMON_H 18 | 19 | #ifndef ASYNC_SIMPLE_USE_MODULES 20 | #include 21 | #include "async_simple/CommonMacros.h" 22 | 23 | #endif // ASYNC_SIMPLE_USE_MODULES 24 | 25 | namespace async_simple { 26 | // Different from assert, logicAssert is meaningful in 27 | // release mode. logicAssert should be used in case that 28 | // we need to make assumption for users. 29 | // In another word, if assert fails, it means there is 30 | // a bug in the library. If logicAssert fails, it means 31 | // there is a bug in the user code. 32 | inline void logicAssert(bool x, const char* errorMsg) { 33 | if (x) 34 | AS_LIKELY { return; } 35 | throw std::logic_error(errorMsg); 36 | } 37 | 38 | } // namespace async_simple 39 | 40 | #endif // ASYNC_SIMPLE_COMMON_H 41 | -------------------------------------------------------------------------------- /async_simple/Unit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef ASYNC_SIMPLE_UNIT_H 17 | #define ASYNC_SIMPLE_UNIT_H 18 | 19 | namespace async_simple { 20 | 21 | // Unit plays the role of a simplest type in case we couldn't 22 | // use void directly. 23 | // 24 | // User shouldn't use this directly. 25 | struct Unit { 26 | constexpr bool operator==(const Unit&) const { return true; } 27 | constexpr bool operator!=(const Unit&) const { return false; } 28 | }; 29 | 30 | } // namespace async_simple 31 | 32 | #endif // ASYNC_SIMPLE_UNIT_H 33 | -------------------------------------------------------------------------------- /async_simple/coro/test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS") 2 | 3 | cc_library( 4 | name = "hdrs_dep", 5 | hdrs = glob(["*.h"]), 6 | copts = ASYNC_SIMPLE_COPTS, 7 | ) 8 | 9 | cc_test( 10 | name = "async_simple_coro_test", 11 | srcs = glob(["*.cpp"]), 12 | deps = [ 13 | "//:async_simple", 14 | "//async_simple/test:gtest_main", 15 | ":hdrs_dep", 16 | ], 17 | copts = ASYNC_SIMPLE_COPTS + select({ 18 | "@platforms//os:windows": [], 19 | # Clang gives incorrect warnings, See https://github.com/llvm/llvm-project/issues/56768 20 | "//conditions:default": ["-Wno-unsequenced"], 21 | }) 22 | ) 23 | -------------------------------------------------------------------------------- /async_simple/coro/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB coro_test_src "*.cpp") 2 | add_compile_options("$<$:/bigobj>") 3 | add_executable(async_simple_coro_test ${coro_test_src} ${PROJECT_SOURCE_DIR}/async_simple/test/dotest.cpp) 4 | 5 | target_link_libraries(async_simple_coro_test async_simple ${deplibs} ${testdeplibs}) 6 | 7 | add_test(NAME run_async_simple_coro_test COMMAND async_simple_coro_test) 8 | -------------------------------------------------------------------------------- /async_simple/coro/test/PMRLazyTest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "async_simple/coro/Lazy.h" 5 | #include "async_simple/coro/SyncAwait.h" 6 | #include "async_simple/test/unittest.h" 7 | 8 | #if __has_include() 9 | #include 10 | #endif 11 | 12 | class PMRLazyTest : public FUTURE_TESTBASE { 13 | public: 14 | void caseSetUp() override {} 15 | void caseTearDown() override {} 16 | }; 17 | 18 | namespace ac = async_simple::coro; 19 | ac::Lazy get_43() { co_return 43; } 20 | ac::Lazy get_43_plus_i(int i = 0) { co_return 43 + i; } 21 | 22 | #if __has_include() 23 | ac::Lazy get_43_plus_i( 24 | std::allocator_arg_t /*unused*/, 25 | std::pmr::polymorphic_allocator<> /*coroutine state allocator*/, 26 | int i = 0) { 27 | int test{}; 28 | test = co_await get_43(); 29 | co_return test + i; 30 | } 31 | #endif 32 | 33 | TEST_F(PMRLazyTest, testStdAllocator) { 34 | auto lazy = get_43(); 35 | int result = ac::syncAwait(lazy); 36 | EXPECT_EQ(result, 43); 37 | 38 | auto lazy2 = get_43_plus_i(1); 39 | int result2 = ac::syncAwait(lazy2); 40 | EXPECT_EQ(result2, 44); 41 | } 42 | 43 | #if __has_include() 44 | TEST_F(PMRLazyTest, testPMRAllocator) { 45 | std::array stack_buffer {}; 46 | std::pmr::monotonic_buffer_resource stack_memory_resource( 47 | stack_buffer.data(), stack_buffer.size()); 48 | std::pmr::polymorphic_allocator stack_allocator(&stack_memory_resource); 49 | auto lazy = get_43_plus_i(std::allocator_arg, stack_allocator, 1); 50 | int result = ac::syncAwait(lazy); 51 | EXPECT_EQ(result, 44); 52 | } 53 | #endif -------------------------------------------------------------------------------- /async_simple/executors/test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS") 2 | 3 | cc_test( 4 | name = "async_simple_executor_test", 5 | srcs = glob(["*.cpp"]), 6 | deps = [ 7 | "//:async_simple", 8 | "//async_simple/test:gtest_main", 9 | ], 10 | copts = ASYNC_SIMPLE_COPTS, 11 | ) 12 | -------------------------------------------------------------------------------- /async_simple/executors/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB executor_test_src "*.cpp") 2 | add_executable(async_simple_executor_test ${executor_test_src} ${PROJECT_SOURCE_DIR}/async_simple/test/dotest.cpp) 3 | 4 | target_link_libraries(async_simple_executor_test async_simple ${deplibs} ${testdeplibs}) 5 | 6 | add_test(NAME run_async_simple_executor_test COMMAND async_simple_executor_test) 7 | 8 | -------------------------------------------------------------------------------- /async_simple/test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS") 2 | 3 | cc_library( 4 | name = "gtest_main", 5 | srcs = ["dotest.cpp"], 6 | hdrs = ["unittest.h"], 7 | deps = [ 8 | "//:simple_executors", 9 | "@com_google_googletest//:gtest" 10 | ], 11 | copts = ASYNC_SIMPLE_COPTS, 12 | visibility = ["//visibility:public"], 13 | ) 14 | 15 | cc_test( 16 | name = "async_simple_test", 17 | srcs = glob(["*Test.cpp"]), 18 | deps = [ 19 | "//:async_simple", 20 | "//async_simple/test:gtest_main", 21 | ], 22 | copts = ASYNC_SIMPLE_COPTS, 23 | ) 24 | -------------------------------------------------------------------------------- /async_simple/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB test_src "*.cpp") 2 | add_executable(async_simple_test ${test_src}) 3 | 4 | target_link_libraries(async_simple_test async_simple ${deplibs} ${testdeplibs}) 5 | 6 | add_test(NAME run_async_simple_test COMMAND async_simple_test) 7 | -------------------------------------------------------------------------------- /async_simple/test/dotest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | using namespace std; 19 | using namespace ::testing; 20 | 21 | int main(int argc, char **argv) { 22 | ::testing::InitGoogleMock(&argc, argv); 23 | int ret = RUN_ALL_TESTS(); 24 | return ret; 25 | } 26 | -------------------------------------------------------------------------------- /async_simple/test/unittest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __ASYNC_SIMPLE_UNITTEST_H 17 | #define __ASYNC_SIMPLE_UNITTEST_H 18 | 19 | #define GTEST_USE_OWN_TR1_TUPLE 0 20 | #include 21 | #include 22 | 23 | class FUTURE_TESTBASE : public testing::Test { 24 | public: 25 | virtual void caseSetUp() = 0; 26 | virtual void caseTearDown() = 0; 27 | 28 | void SetUp() override { caseSetUp(); } 29 | 30 | void TearDown() override { caseTearDown(); } 31 | }; 32 | 33 | #endif //__ASYNC_SIMPLE_UNITTEST_H 34 | -------------------------------------------------------------------------------- /async_simple/uthread/test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS") 2 | 3 | cc_test( 4 | name = "async_simple_uthread_test", 5 | srcs = select({ 6 | "//bazel/config:async_simple_with_uthread" : glob(["*.cpp"]), 7 | "//conditions:default" : [], 8 | }), 9 | deps = [ 10 | "//:async_simple", 11 | "//async_simple/test:gtest_main", 12 | ], 13 | copts = ASYNC_SIMPLE_COPTS, 14 | ) 15 | -------------------------------------------------------------------------------- /async_simple/uthread/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB uthread_test_src "*.cpp") 2 | 3 | if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND 4 | CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13") 5 | endif() 6 | 7 | add_executable(async_simple_uthread_test ${uthread_test_src} ${PROJECT_SOURCE_DIR}/async_simple/test/dotest.cpp) 8 | 9 | target_link_libraries(async_simple_uthread_test async_simple ${deplibs} ${testdeplibs}) 10 | 11 | add_test(NAME run_async_simple_uthread_test COMMAND async_simple_uthread_test) 12 | 13 | -------------------------------------------------------------------------------- /async_simple/util/test/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS") 2 | 3 | cc_test( 4 | name = "async_simple_util_test", 5 | srcs = glob(["*.cpp"]), 6 | deps = [ 7 | "//:async_simple", 8 | "//async_simple/test:gtest_main", 9 | ], 10 | copts = ASYNC_SIMPLE_COPTS, 11 | ) 12 | -------------------------------------------------------------------------------- /async_simple/util/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB util_test_src "*.cpp") 2 | add_executable(async_simple_util_test ${util_test_src} ${PROJECT_SOURCE_DIR}/async_simple/test/dotest.cpp) 3 | 4 | target_link_libraries(async_simple_util_test async_simple ${deplibs} ${testdeplibs}) 5 | 6 | add_test(NAME run_async_simple_util_test COMMAND async_simple_util_test) 7 | -------------------------------------------------------------------------------- /bazel/config/copt.bzl: -------------------------------------------------------------------------------- 1 | ASYNC_SIMPLE_COPTS = select({ 2 | "@com_github_async_simple//bazel/config:msvc_compiler": [ 3 | "/std:c++20", 4 | "/await:strict", 5 | "/EHa" 6 | ], 7 | "//conditions:default": [ 8 | "-std=c++20", 9 | "-D_GLIBCXX_USE_CXX11_ABI=1", 10 | "-Wno-deprecated-register", 11 | "-Wno-mismatched-new-delete", 12 | "-Wno-deprecated-declarations", 13 | "-fPIC", 14 | "-Wall", 15 | "-Werror", 16 | "-D__STDC_LIMIT_MACROS", 17 | "-g", 18 | ], 19 | }) 20 | -------------------------------------------------------------------------------- /bazel/config/deps.bzl: -------------------------------------------------------------------------------- 1 | """Load dependencies needed to use the async_simple library as a 3rd-party consumer.""" 2 | 3 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4 | 5 | def async_simple_dependencies(): 6 | if not native.existing_rule("bazel_skylib"): 7 | http_archive( 8 | name = "bazel_skylib", 9 | sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", 10 | urls = [ 11 | "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", 12 | "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", 13 | ], 14 | ) 15 | if not native.existing_rule("platforms"): 16 | http_archive( 17 | name = "platforms", 18 | urls = [ 19 | "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", 20 | "https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", 21 | ], 22 | sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca", 23 | ) 24 | -------------------------------------------------------------------------------- /bazel/support/BUILD.bazel: -------------------------------------------------------------------------------- 1 | config_setting( 2 | name = "msvc_compiler", 3 | flag_values = { 4 | "@bazel_tools//tools/cpp:compiler": "msvc-cl", 5 | }, 6 | ) 7 | 8 | cc_binary( 9 | name = "hello", 10 | srcs = ["hello.cc"], 11 | copts = select({ 12 | ":msvc_compiler": ["/std:c++20"], 13 | "//conditions:default": ["-std=c++20"], 14 | }), 15 | deps = ["@com_github_async_simple//:async_simple"], 16 | ) 17 | -------------------------------------------------------------------------------- /bazel/support/WORKSPACE.bazel: -------------------------------------------------------------------------------- 1 | workspace(name = "hello_async_simple") 2 | 3 | load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") 4 | 5 | ASYNC_SIMPLE_COMMID_ID = "8ccc63142b23c6660f61d58f08a151020fa39da0" 6 | 7 | git_repository( 8 | name = "com_github_async_simple", 9 | commit = ASYNC_SIMPLE_COMMID_ID, 10 | remote = "https://github.com/alibaba/async_simple.git", 11 | ) 12 | 13 | # Load async_simple async_simple_dependencies 14 | load("@com_github_async_simple//bazel/config:deps.bzl", "async_simple_dependencies") 15 | 16 | async_simple_dependencies() 17 | -------------------------------------------------------------------------------- /bazel/support/hello.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "async_simple/coro/Lazy.h" 19 | 20 | async_simple::coro::Lazy hello() { co_return "Hello World"; } 21 | 22 | int main() { 23 | hello().start([](auto&& result) { 24 | if (!result.hasError()) { 25 | std::cout << result.value() << std::endl; 26 | } 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /benchmarks/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("//bazel/config:copt.bzl", "ASYNC_SIMPLE_COPTS") 2 | 3 | cc_library( 4 | name = "benchmark_main", 5 | srcs = ["benchmark_main.cpp"], 6 | hdrs = glob(["*.h", "*.hpp"]), 7 | deps = [ 8 | "//:async_simple", 9 | "//:simple_executors", 10 | "@com_google_benchmark//:benchmark", 11 | ], 12 | defines = select({ 13 | "//bazel/config:async_simple_with_uthread" : ["ASYNC_SIMPLE_BENCHMARK_UTHREAD"], 14 | "//conditions:default" : [], 15 | }), 16 | copts = ASYNC_SIMPLE_COPTS, 17 | ) 18 | 19 | cc_binary( 20 | name = "benchmarking", 21 | srcs = [ 22 | "PureSwitch.bench.cpp", 23 | "ReadFile.bench.cpp", 24 | "CallDepth.bench.cpp", 25 | "Lazy.bench.cpp", 26 | "Future.bench.cpp", 27 | "ThreadPool.bench.cpp", 28 | "Mutex.bench.cpp", 29 | "SpinLock.bench.cpp", 30 | "SharedMutex.bench.cpp" 31 | ] + select({ 32 | "//bazel/config:async_simple_with_uthread": ["Uthread.bench.cpp"], 33 | "//conditions:default": [], 34 | }), 35 | deps = [":benchmark_main"], 36 | copts = ASYNC_SIMPLE_COPTS, 37 | ) 38 | -------------------------------------------------------------------------------- /benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BENCHMARK_SRCS 2 | benchmark_main.cpp 3 | PureSwitch.bench.cpp 4 | ReadFile.bench.cpp 5 | CallDepth.bench.cpp 6 | Lazy.bench.cpp 7 | Future.bench.cpp 8 | ThreadPool.bench.cpp 9 | Mutex.bench.cpp 10 | SpinLock.bench.cpp 11 | SharedMutex.bench.cpp) 12 | 13 | if (UTHREAD) 14 | list(APPEND BENCHMARK_SRCS Uthread.bench.cpp) 15 | add_compile_definitions(ASYNC_SIMPLE_BENCHMARK_UTHREAD) 16 | endif() 17 | 18 | add_executable(benchmarking ${BENCHMARK_SRCS}) 19 | target_link_libraries(benchmarking ${BENCHMARK_LIBRARIES} async_simple) 20 | 21 | if(NOT ${ASYNC_SIMPLE_DISABLE_AIO} AND LIBAIO_INCLUDE_DIR AND LIBAIO_LIBRARIES) 22 | target_link_libraries(benchmarking ${LIBAIO_LIBRARIES}) 23 | endif() 24 | -------------------------------------------------------------------------------- /benchmarks/CallDepth.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "benchmark/benchmark.h" 17 | void Lazy_call_depth_bench(benchmark::State &state); 18 | void Uthread_call_depth_bench(benchmark::State &state); 19 | -------------------------------------------------------------------------------- /benchmarks/Future.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "benchmark/benchmark.h" 17 | 18 | void Future_chain(benchmark::State& state); 19 | void Future_collectAll(benchmark::State& state); 20 | -------------------------------------------------------------------------------- /benchmarks/Lazy.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "benchmark/benchmark.h" 17 | 18 | void async_simple_Lazy_chain(benchmark::State& state); 19 | void async_simple_Lazy_collectAll(benchmark::State& state); 20 | void RescheduleLazy_chain(benchmark::State& state); 21 | void RescheduleLazy_collectAll(benchmark::State& state); 22 | -------------------------------------------------------------------------------- /benchmarks/Mutex.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "benchmark/benchmark.h" 17 | 18 | void Mutex_chain(benchmark::State& state); 19 | -------------------------------------------------------------------------------- /benchmarks/PureSwitch.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "benchmark/benchmark.h" 17 | void Generator_pure_switch_bench(benchmark::State &state); 18 | void Uthread_pure_switch_bench(benchmark::State &state); 19 | -------------------------------------------------------------------------------- /benchmarks/ReadFile.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | void Uthread_read_diff_size_bench(benchmark::State &state); 18 | void Uthread_same_read_bench(benchmark::State &state); 19 | void Lazy_read_diff_size_bench(benchmark::State &state); 20 | void Lazy_same_read_bench(benchmark::State &state); 21 | -------------------------------------------------------------------------------- /benchmarks/SharedMutex.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | void SharedMutex_ReadMoreThanWrite_chain(benchmark::State &state); 18 | void SpinLock_ReadMoreThanWrite_chain(benchmark::State &state); 19 | -------------------------------------------------------------------------------- /benchmarks/SpinLock.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "benchmark/benchmark.h" 18 | 19 | void SpinLock_diff_spin_count_bench(benchmark::State& state); 20 | void SpinLock_thread_lock_bench(benchmark::State& state); 21 | void SpinLock_coroutine_lock_bench(benchmark::State& state); -------------------------------------------------------------------------------- /benchmarks/ThreadPool.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "async_simple/util/ThreadPool.h" 17 | #include "benchmark/benchmark.h" 18 | 19 | void ThreadPool_noWorkSteal(benchmark::State& state); 20 | void ThreadPool_withWorkSteal(benchmark::State& state); 21 | -------------------------------------------------------------------------------- /benchmarks/Uthread.bench.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022, Alibaba Group Holding Limited; 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "async_simple/uthread/Async.h" 17 | #include "async_simple/uthread/Await.h" 18 | #include "async_simple/uthread/Collect.h" 19 | #include "benchmark/benchmark.h" 20 | 21 | void Uthread_switch(benchmark::State& state); 22 | void Uthread_async(benchmark::State& state); 23 | void Uthread_await(benchmark::State& state); 24 | void Uthread_collectAll(benchmark::State& state); 25 | -------------------------------------------------------------------------------- /cmake/FindAio.cmake: -------------------------------------------------------------------------------- 1 | message(STATUS "FindAio.cmake: ${AIO_ROOT}") 2 | if("${AIO_ROOT}" STREQUAL "") 3 | set(AIO_ROOT "/usr") 4 | endif() 5 | 6 | find_path(LIBAIO_INCLUDE_DIR NAMES libaio.h 7 | PATHS ${AIO_ROOT}/include/) 8 | 9 | find_library(LIBAIO_LIBRARIES NAME aio 10 | PATHS ${AIO_ROOT}/lib/) 11 | 12 | if(NOT TARGET aio) 13 | add_library(aio SHARED IMPORTED) 14 | set_target_properties(aio 15 | PROPERTIES INTERFACE_INCLUDE_DIRECTORIES 16 | "${LIBAIO_INCLUDE_DIR}" 17 | IMPORTED_LOCATION 18 | "${LIBAIO_LIBRARIES}") 19 | endif() 20 | 21 | include(FindPackageHandleStandardArgs) 22 | find_package_handle_standard_args(Aio DEFAULT_MSG LIBAIO_LIBRARIES) 23 | mark_as_advanced(LIBAIO_INCLUDE_DIR LIBAIO_LIBRARIES) 24 | -------------------------------------------------------------------------------- /cmake/FindBenchmark.cmake: -------------------------------------------------------------------------------- 1 | if("${BENCHMARK_ROOT}" STREQUAL "") 2 | set(BENCHMARK_ROOT "/usr/local") 3 | endif() 4 | 5 | find_path(BENCHMARK_INCLUDE_DIR 6 | NAMES benchmark/benchmark.h 7 | PATHS ${BENCHMARK_ROOT}/include) 8 | 9 | find_library(BENCHMARK_LIBRARIES 10 | NAME benchmark 11 | PATHS ${GOOGLETEST_ROOT}) 12 | 13 | if (NOT TARGET benchmark) 14 | add_library(benchmark STATIC IMPORTED) 15 | set_target_properties(benchmark 16 | PROPERTIES INTERFACE_COMPILE_DEFINITIONS 17 | HAS_BENCHMARK 18 | INTERFACE_INCLUDE_DIRECTORIES 19 | "${BENCHMARK_INCLUDE_DIR}" 20 | IMPORTED_LOCATION 21 | "${BENCHMARK_LIBRARIES}") 22 | endif() 23 | 24 | include(FindPackageHandleStandardArgs) 25 | find_package_handle_standard_args(Benchmark DEFAULT_MSG BENCHMARK_LIBRARIES BENCHMARK_INCLUDE_DIR) 26 | 27 | MARK_AS_ADVANCED( 28 | BENCHMARK_INCLUDE_DIR 29 | BENCHMARK_LIBRARIES) 30 | 31 | -------------------------------------------------------------------------------- /cmake/FindGTest.cmake: -------------------------------------------------------------------------------- 1 | if (DEFINED GMOCK_INCLUDE_DIR AND DEFINED GTEST_INCLUDE_DIR 2 | AND DEFINED GTEST_LIBRARIES AND DEFINED GMOCK_LIBRARIES) 3 | message(STATUS "Using GTest from specified path") 4 | else() 5 | message(STATUS "Not all GTest variable got specified: " 6 | "'GMOCK_INCLUDE_DIR', 'GTEST_INCLUDE_DIR', " 7 | "'GTEST_LIBRARIES', 'GMOCK_LIBRARIES'") 8 | message(STATUS "fetch GTest from https://github.com/google/googletest.git") 9 | include(FetchContent) 10 | FetchContent_Declare( 11 | googletest 12 | GIT_REPOSITORY https://github.com/google/googletest.git 13 | GIT_TAG release-1.11.0 14 | GIT_SHALLOW ON 15 | ) 16 | 17 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 18 | set(BUILD_GMOCK ON CACHE BOOL "" FORCE) 19 | set(BUILD_GTEST ON CACHE BOOL "" FORCE) 20 | FetchContent_MakeAvailable(googletest) 21 | set(GMOCK_INCLUDE_DIR ${CMAKE_BINARY_DIR}/_deps/googletest-src/googlemock/include/) 22 | set(GTEST_INCLUDE_DIR ${CMAKE_BINARY_DIR}/_deps/googletest-src/googletest/include/) 23 | set(GTEST_LIBRARIES gtest_main) 24 | set(GMOCK_LIBRARIES gmock_main) 25 | endif() 26 | 27 | message(STATUS "GTest: ${GTEST_INCLUDE_DIR}, ${GTEST_LIBRARIES}") 28 | message(STATUS "GMock: ${GMOCK_INCLUDE_DIR}, ${GMOCK_LIBRARIES}") 29 | -------------------------------------------------------------------------------- /cmake/IsACC.cpp: -------------------------------------------------------------------------------- 1 | #ifndef __alibaba_clang__ 2 | #error "The current compiler is not ACC" 3 | #endif 4 | -------------------------------------------------------------------------------- /cxx_modules_rules_clang.cmake: -------------------------------------------------------------------------------- 1 | set(CMake_TEST_CXXModules_UUID "a246741c-d067-4019-a8fb-3d16b0c9d1d3") 2 | set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1) 3 | string(CONCAT CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE 4 | "${CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS}" 5 | " -format=p1689" 6 | " --" 7 | " " 8 | " -x c++ -c -o " 9 | " -MT " 10 | " -MD -MF " 11 | " > ") 12 | set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "clang") 13 | set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "@") 14 | 15 | # Default to C++ extensions being off. Clang's modules support have trouble 16 | # with extensions right now. 17 | set(CMAKE_CXX_EXTENSIONS OFF) 18 | -------------------------------------------------------------------------------- /demo_example/asio/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) 2 | 3 | Distributed under the Boost Software License, Version 1.0. (See accompanying 4 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | -------------------------------------------------------------------------------- /demo_example/asio/LICENSE_1_0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /demo_example/asio/asio/associator.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // associator.hpp 3 | // ~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef ASIO_ASSOCIATOR_HPP 12 | #define ASIO_ASSOCIATOR_HPP 13 | 14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | # pragma once 16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 17 | 18 | #include "asio/detail/config.hpp" 19 | 20 | #include "asio/detail/push_options.hpp" 21 | 22 | namespace asio { 23 | 24 | /// Used to generically specialise associators for a type. 25 | template