RFoe / coasync

Asynchronous network library that supports coroutines in C++20
https://github.com/RFoe/coasync
MIT License
51 stars 5 forks source link

将select改成IOCP(Win) / EPOLL(Linux) #23

Closed RFoe closed 1 month ago

RFoe commented 1 month ago

https://github.com/RFoe/coasync/blob/783cf5397e23745ec6f1074b8c5f55c32310385f/include/coasync/detail/service/socket_service.hpp#L61

或许是这样


#if defined(_WIN32) || defined(_WIN64)
template <typename execution_constext, bool subscribe_sockin>
using basic_socket_service = basic_iocp_service<execution_context, subscribe_sockin>;
#elif defined(__linux__) && __has_include(<sys/epoll.h>)
template <typename execution_constext, bool subscribe_sockin>
using basic_socket_service = basic_epoll_service<execution_context, subscribe_sockin>;
#endif
RFoe commented 1 month ago

https://github.com/RFoe/coasync/blob/29491e884302dd7dc776a915ebbd86777f74931a/include/coasync/detail/service/iocp_socket_service.hpp#L39 https://github.com/RFoe/coasync/blob/29491e884302dd7dc776a915ebbd86777f74931a/include/coasync/detail/service/iocp_socket_service.hpp#L64

IOCP是windows上以proacter形式提供的IO异步机制,但我的项目是封装reacter到coroutine的(broadcast -> send/recv),大概率不能优雅的将iocp融入项目中了。 Epoll没有问题

naonao-cola commented 1 month ago

自己给自己提issue啊?能不能写写workflows,我之前搞来着,mac的workflows不支持c++20,linux好像也有点难搞。没搞通过。要是有的话,我借鉴下博主的代码。哈哈哈哈哈。我从知乎看来的。

RFoe commented 1 month ago

@naonao-cola 我不太了解workflows怎么写欸,没有这方面的经验