Skip to content

xing-cg/Agave

 
 

Repository files navigation

epoll+Agave

服务器单线程: 100个连接,每个连接1000条消息: echo_epoll:2.200s echo_阻塞版:3.108s

1000个连接,每个连接10000条消息: echo_epoll:263.511s

服务器多线程:(单accept + eventfd) 100个连接,每个连接1000条消息: echo_epoll:2.800s 1000个连接,每个连接10000条消息: echo_epoll:340.827s

服务器多线程:(每个线程均accept - SO_REUSEPORT) 100个连接,每个连接1000条消息: echo_epoll_reuseport:2.780s

服务器多线程: 10000个连接,每个连接10条消息: echo_epoll_eventfd:4.813s echo_epoll_reuseport:4.950s

1000个连接,每个连接10000条消息:

Agave (TM) C++20 Standard Coroutine Library Framework

  • Following the C++20 standard, it has excellent performance, is easy to use, and is suitable for use by coroutine library (middleware) developers and end users.

  • Designed universal Coroutine Return types: AsyncAction, AsyncActionWithProgress, AsyncOperation, AsyncOperationWithProgress ...

  • Almost all operations, such as environment switching, feature settings, etc., can be completed using only the standard keyword: co_await. Such as: co_await agave::resume_background(); co_await agave::resume_foreground(); Enter the background or foreground thread environment, co_wait agave::get_cancellation_token(); Obtain stop tokens, etc.

  • Support custom progress types for progress mechanism, which can also be obtained and manipulated through the standard keyword: co_wait.

  • Highly scalable design, all execution environments can be configured, such as front-end, back-end, time scheduling, etc., all of which can be configured to connect to custom efficient thread pools.

Quick Start

//--------------------------------------------------------------------
//	demo.cpp.
//	09/27/2022.				created.
//	09/20/2024.				last modified.
//--------------------------------------------------------------------
//	*	Demonstrations of Agave(TM) Coroutine Framework 
//		(based on ISO C++20 or later).
//	*	if has any questions, 
//	*	please contact me at 'full1900@outlook.com'.
//	*	by bubo.
//--------------------------------------------------------------------
#include "Agave.hpp"
#include <iostream>

using namespace std::chrono_literals;

//--------------------------------------------------------------------
agave::AsyncOperation<int> foo(void);

//--------------------------------------------------------------------
int main(void)
{
	auto v = foo().get();           // classical blocked method.    
	std::cout << "got the value on thread: " << std::this_thread::get_id() << std::endl;
	std::cout << v << std::endl;
	return 0;
}

//--------------------------------------------------------------------
agave::AsyncAction action_async(void)
{
	std::cout << "action started on thread: " << std::this_thread::get_id() << std::endl;
	co_await agave::resume_background();
	std::cout << "do action in 2s... on thread: " << std::this_thread::get_id() << std::endl;
	co_await 2s;
	std::cout << "do action in 2s done... on thread: " << std::this_thread::get_id() << std::endl;
}

//--------------------------------------------------------------------
agave::AsyncOperation<int> operation_async(void)
{
	std::cout << "operation started on thread: " << std::this_thread::get_id() << std::endl;
	co_await agave::resume_background();
	std::cout << "do operation in 3s... on thread: " << std::this_thread::get_id() << std::endl;
	co_await 3s;

	co_return 51;
}

//--------------------------------------------------------------------
agave::AsyncOperation<int> foo(void)
{
    co_await action_async();
    auto&& v = co_await operation_async();    
    co_return v + 10;
}

//--------------------------------------------------------------------

Contract and Approvals

Submitted by Role Contact Date
Bo Bu (full1900) Agave (TM) Designer
and Programming Leader
full1900@outlook.com
full1900@vip.163.com
22 Sep 2024

About

Agave (TM) C++20 Standard Coroutine Library Framework

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 98.4%
  • Other 1.6%