# libcorocxx **Repository Path**: crazyhero/libcorocxx ## Basic Information - **Project Name**: libcorocxx - **Description**: C++协程库。参照libcoro协程库进行C++的封装,使用句柄自行管理协程资源。 - **Primary Language**: C++ - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 2 - **Created**: 2017-02-20 - **Last Updated**: 2024-07-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #libcorocxx 1. c++的协程库,参考libcoro库。 2. 支持MacOS,Windows,Linux三个平台。 3. 使用cmake进行项目编译管理。 ```cpp class Hi : public CoroFunc { public: Hi(const std::string msg) : _msg(msg) { } void operator()(const Coro &coro) { std::cout << "first hello:" << _msg << std::endl; coro.yield(Coro::getMainCoro()); std::cout << "second hello:" << _msg << std::endl; coro.stop(Coro::getMainCoro()); std::cout << "??? :" << _msg << std::endl; } private: std::string _msg; }; int main() { { Hi china("China"); Coro chinaCoro(&china); std::cout << "main start" << std::endl; Coro::getMainCoro().yield(chinaCoro); std::cout << "main restore" << std::endl; Coro::getMainCoro().yield(chinaCoro); std::cout << "main end" << std::endl; } #ifdef _WIN32 getchar(); #endif return EXIT_SUCCESS; } ```