Skip to content

Commit

Permalink
添加协程递归调用测试,用于说明协程递归调用不受限于栈内存大小
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed Oct 5, 2024
1 parent a1c06ad commit 7601e31
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ if(Qt6_FOUND)
endif(Qt6_FOUND)

add_subdirectory(test4)
add_subdirectory(test6)
6 changes: 6 additions & 0 deletions tests/test6/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

add_executable(test6 test.cpp)
target_link_libraries(test6 ucoro)

add_test(NAME test6 COMMAND test6)
set_target_properties(test6 PROPERTIES FOLDER "ucoro_tests")
20 changes: 20 additions & 0 deletions tests/test6/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#define DISABLE_DEBUG_CORO_STACK
#include "ucoro/awaitable.hpp"


ucoro::awaitable<void> coro_compute_exec(int value)
{
if (value == 0)
co_return;

co_await coro_compute_exec(--value);

co_return;
}

int main(int argc, char **argv)
{
coro_start(coro_compute_exec(1000));
return 0;
}

0 comments on commit 7601e31

Please sign in to comment.