From ee4a1b0b77f326eb1791e8f0a3c7ed94f2d138e5 Mon Sep 17 00:00:00 2001 From: microcai Date: Sat, 5 Oct 2024 14:00:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=AA=E5=9C=B0=E6=96=B9=EF=BC=8C?= =?UTF-8?q?=E8=83=BD=20=20=E6=8A=93=E5=88=B0=20=E5=BC=82=E5=B8=B8=E3=80=82?= =?UTF-8?q?=E7=9C=8B=E6=9D=A5=E5=8F=AA=E6=9C=89=E8=BF=99=E7=A7=8D=E5=9C=B0?= =?UTF-8?q?=E6=96=B9=E7=9A=84=E5=BC=82=E5=B8=B8=E8=83=BD=E6=8A=93=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test5/test.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test5/test.cpp b/tests/test5/test.cpp index d95ef76..fe2735c 100644 --- a/tests/test5/test.cpp +++ b/tests/test5/test.cpp @@ -10,12 +10,19 @@ ucoro::awaitable coro_compute_int(int value) auto ret = co_await executor_awaitable([value](auto handle) { main_ioc.post([value, handle = std::move(handle)]() mutable { std::this_thread::sleep_for(std::chrono::seconds(0)); - throw std::bad_alloc{}; std::cout << value << " value\n"; + + // 这里调用后,重新进入协程框架. handle(value * 100); }); + + // 这里 return 后,就出协程框架了. }); + + // 放这里能抓到 + throw std::bad_alloc{}; + co_return (value + ret); }