co_async
co_async copied to clipboard
C++20 Coroutine Library for Education Purpose (WIP)
问题描述:小彭老师好,在step24中,接收到http请求后,通过spawn_task函数创建一个协程处理新的连接,在[s.getline()](https://github.com/archibate/co_async/blob/424a5a9fe7b80445ba4b1b7eaf3cfef1d43e4667/steps/step24.cpp#L16)这行代码上无法得到返回,导致handle_connection后续的部分无法得到执行,浏览器也得不到回传的报文。 请问小彭老师能否修复一下这个bug,个人能力有限,尝试修复后还是无法解决。
`await_suspend`需要判断`mPrevious`是否有效,否则在`main()`中创建的协程会恢复一个不存在的调用者。
求助
我在 steps3.cpp 中将 40 行的 return PreviousAwaiter(mPrevious); 修改成了 return std::suspend_always(); 结果发现 world 协程 co_return 后没有返回到 hello 协成中的 co_await word() 处,按理 world 协成 co_return 完后应该会将控制权交还给之前 co_await 它的协成,求帮瞅瞅这里如何理解 auto final_suspend() noexcept {...
https://github.com/archibate/co_async/blob/f342eedf6b8aa1d1d5a5c1cf0319fc1a46d28a5f/steps/step7.cpp#L231 https://github.com/archibate/co_async/blob/f342eedf6b8aa1d1d5a5c1cf0319fc1a46d28a5f/steps/step7.cpp#L246 ``` #include "co_async/rbtree.hpp" #include "co_async/debug.hpp" ``` RbTree这里我改成了co_async::RbTree, rbtree.hpp和debug.hpp都加了“co_async/”编译通过的 🍟Cheers!
求助小彭老师! socket.hpp(9,10): fatal error C1083: Cannot open include file: 'sys/socket.h': No such file or directory socket.hpp不支持windows系统,目前没有linux系统
add mirror
```cmake if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) file(GLOB example_sources examples/*.cpp) + list(REMOVE_ITEM example_sources ${PROJECT_SOURCE_DIR}/examples/code_assistant.cpp) foreach(path ${example_sources}) get_filename_component(name ${path} NAME_WE) add_executable(${name} ${path}) target_link_libraries(${name} PRIVATE co_async) endforeach() endif() ``` code_assistant 中的代码无法编译,建议在 CMake 文件中添加以上行,暂时先不编译。 系统信息:...
在HTTPServer::doHandleConnection()这个函数中, 我将 /*if (!co_await co_await io.readRequestHeader()) { break; }*/ 替换为: auto headerResult = co_await io.readRequestHeader(); if (headerResult.has_error() && headerResult.error() == std::errc::stream_timeout) { co_await io.extractSocket().close(); break; } 解决了超时连接不能释放的问题,希望小彭老师修改一下