From 8212b976062dd28fbfaf75f6b5d57491bff27667 Mon Sep 17 00:00:00 2001 From: tearshark Date: Tue, 26 May 2020 11:52:53 +0800 Subject: [PATCH 1/4] =?UTF-8?q?clang=E5=85=BC=E5=AE=B9msvc=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=EF=BC=8C=E5=AF=B9=E5=BC=82=E5=B8=B8=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=9C=89=E6=94=B9=E8=BF=9B=E3=80=82=E4=BD=86=E4=BE=9D?= =?UTF-8?q?=E7=84=B6=E5=AD=98=E5=9C=A8=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- librf/src/state.inl | 2 +- test_librf.cpp | 8 ++++---- tutorial/test_async_cb.cpp | 1 + tutorial/test_async_exception.cpp | 15 +++++++++------ tutorial/test_async_modern_cb.cpp | 1 + tutorial/test_async_resumable.cpp | 1 + tutorial/test_async_routine.cpp | 1 + tutorial/test_async_suspend_always.cpp | 1 + tutorial/test_async_yield_return.cpp | 1 + 9 files changed, 20 insertions(+), 11 deletions(-) diff --git a/librf/src/state.inl b/librf/src/state.inl index 2da5c7c..9eae473 100644 --- a/librf/src/state.inl +++ b/librf/src/state.inl @@ -111,7 +111,7 @@ namespace resumef std::rethrow_exception(std::make_exception_ptr(future_exception{ error_code::not_ready })); break; case result_type::Exception: - std::rethrow_exception(std::move(this->_exception)); + std::rethrow_exception(std::exchange(this->_exception, nullptr)); break; default: break; diff --git a/test_librf.cpp b/test_librf.cpp index fa52aef..336c581 100644 --- a/test_librf.cpp +++ b/test_librf.cpp @@ -9,7 +9,7 @@ extern void resumable_main_sleep(); extern void resumable_main_routine(); extern void resumable_main_resumable(); extern void resumable_main_mutex(); -extern void resumable_main_exception(); +extern void resumable_main_exception(bool bomb); extern void resumable_main_event(); extern void resumable_main_event_v2(); extern void resumable_main_event_timeout(); @@ -36,8 +36,8 @@ int main(int argc, const char* argv[]) (void)argc; (void)argv; - //test_async_cinatra_client(); - //return 0; + resumable_main_exception(false); + return 0; //if (argc > 1) // resumable_main_benchmark_asio_client(atoi(argv[1])); @@ -51,7 +51,7 @@ int main(int argc, const char* argv[]) resumable_main_yield_return(); resumable_main_resumable(); resumable_main_routine(); - resumable_main_exception(); + resumable_main_exception(false); resumable_main_dynamic_go(); resumable_main_multi_thread(); resumable_main_timer(); diff --git a/tutorial/test_async_cb.cpp b/tutorial/test_async_cb.cpp index f2e4ed5..7e2de67 100644 --- a/tutorial/test_async_cb.cpp +++ b/tutorial/test_async_cb.cpp @@ -83,6 +83,7 @@ static future_t resumable_get_string(std::string& val) void resumable_main_cb() { + std::cout << __FUNCTION__ << std::endl; //由于使用者可能不能明确的区分是resume function返回的awaitor还是awaitable function返回的awaitor //导致均有可能加入到协程里去调度。 //所以,协程调度器应该需要能处理这种情况。 diff --git a/tutorial/test_async_exception.cpp b/tutorial/test_async_exception.cpp index dc57dba..be359bc 100644 --- a/tutorial/test_async_exception.cpp +++ b/tutorial/test_async_exception.cpp @@ -56,9 +56,9 @@ future_t<> test_signal_exception() auto r = co_await async_signal_exception2(i); std::cout << "result is " << r << std::endl; } - catch (const std::exception& e) + catch (const std::exception& ex) { - std::cout << "exception signal : " << e.what() << std::endl; + std::cout << "exception signal : " << ex.what() << std::endl; } catch (...) { @@ -76,13 +76,16 @@ future_t<> test_bomb_exception() } } -void resumable_main_exception() +void resumable_main_exception(bool bomb) { + std::cout << __FUNCTION__ << std::endl; go test_signal_exception(); this_scheduler()->run_until_notask(); std::cout << std::endl; - - go test_bomb_exception(); - this_scheduler()->run_until_notask(); + if (bomb) + { + go test_bomb_exception(); + this_scheduler()->run_until_notask(); + } } diff --git a/tutorial/test_async_modern_cb.cpp b/tutorial/test_async_modern_cb.cpp index 12f166e..a096bae 100644 --- a/tutorial/test_async_modern_cb.cpp +++ b/tutorial/test_async_modern_cb.cpp @@ -151,6 +151,7 @@ static void example_librf() void resumable_main_modern_cb() { + std::cout << __FUNCTION__ << std::endl; example_future(); example_librf(); } \ No newline at end of file diff --git a/tutorial/test_async_resumable.cpp b/tutorial/test_async_resumable.cpp index 3e8911d..814dd85 100644 --- a/tutorial/test_async_resumable.cpp +++ b/tutorial/test_async_resumable.cpp @@ -53,6 +53,7 @@ void resumable_switch(intptr_t coro, size_t idx) void resumable_main_resumable() { + std::cout << __FUNCTION__ << std::endl; resumable_switch(1, 99); resumable_switch(1, 0); diff --git a/tutorial/test_async_routine.cpp b/tutorial/test_async_routine.cpp index 5926c9c..6a19145 100644 --- a/tutorial/test_async_routine.cpp +++ b/tutorial/test_async_routine.cpp @@ -36,6 +36,7 @@ future_t<> test_routine_use_timer_2() void resumable_main_routine() { + std::cout << __FUNCTION__ << std::endl; //go test_routine_use_timer_2(); #ifndef __GNUC__ //GCC: ûṩ__builtin_coro_frameú go test_routine_use_timer(); diff --git a/tutorial/test_async_suspend_always.cpp b/tutorial/test_async_suspend_always.cpp index 5116379..bab171c 100644 --- a/tutorial/test_async_suspend_always.cpp +++ b/tutorial/test_async_suspend_always.cpp @@ -50,6 +50,7 @@ future_t<> test_recursive_go() void resumable_main_suspend_always() { + std::cout << __FUNCTION__ << std::endl; go test_recursive_await(); go test_recursive_go(); this_scheduler()->run_until_notask(); diff --git a/tutorial/test_async_yield_return.cpp b/tutorial/test_async_yield_return.cpp index 5d619bb..50d93eb 100644 --- a/tutorial/test_async_yield_return.cpp +++ b/tutorial/test_async_yield_return.cpp @@ -73,6 +73,7 @@ auto test_yield_future() -> future_t void resumable_main_yield_return() { + std::cout << __FUNCTION__ << std::endl; for (int i : test_yield_int()) { std::cout << i << " had return" << std::endl; From 1a2b2db389e6f30bbb0ef8610b7412c44fb43323 Mon Sep 17 00:00:00 2001 From: tearshark Date: Tue, 26 May 2020 11:53:35 +0800 Subject: [PATCH 2/4] Merge branch 'master' of https://github.com/tearshark/librf --- modern_cb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modern_cb b/modern_cb index b3b4614..6c3135d 160000 --- a/modern_cb +++ b/modern_cb @@ -1 +1 @@ -Subproject commit b3b4614af0a37cae4c903c86b4f234fc5f96c38e +Subproject commit 6c3135d07e1d935ea924f61a11307bf5e466dec9 From 956d5d341b5ce3020139be28a41bd1e4baeb7005 Mon Sep 17 00:00:00 2001 From: tearshark Date: Tue, 26 May 2020 11:56:00 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=B0=9D=E8=AF=95clang=E7=9A=84=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_librf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_librf.cpp b/test_librf.cpp index 336c581..c589993 100644 --- a/test_librf.cpp +++ b/test_librf.cpp @@ -36,8 +36,8 @@ int main(int argc, const char* argv[]) (void)argc; (void)argv; - resumable_main_exception(false); - return 0; + //resumable_main_exception(false); + //return 0; //if (argc > 1) // resumable_main_benchmark_asio_client(atoi(argv[1])); From 76c03f5855579633a7dc83ff8a3e7e35c19657be Mon Sep 17 00:00:00 2001 From: tearshark Date: Tue, 26 May 2020 12:04:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?Linux=E6=8E=92=E9=99=A4cinatra=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test_async_cinatra_client.cpp | 0 vs_proj/librf.vcxproj | 12 ++++++------ vs_proj/librf.vcxproj.filters | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) rename {tutorial => benchmark}/test_async_cinatra_client.cpp (100%) diff --git a/tutorial/test_async_cinatra_client.cpp b/benchmark/test_async_cinatra_client.cpp similarity index 100% rename from tutorial/test_async_cinatra_client.cpp rename to benchmark/test_async_cinatra_client.cpp diff --git a/vs_proj/librf.vcxproj b/vs_proj/librf.vcxproj index ab71ea4..174e542 100644 --- a/vs_proj/librf.vcxproj +++ b/vs_proj/librf.vcxproj @@ -190,6 +190,12 @@ + + true + true + true + true + @@ -205,12 +211,6 @@ - - true - true - true - true - diff --git a/vs_proj/librf.vcxproj.filters b/vs_proj/librf.vcxproj.filters index d7bbc46..101c552 100644 --- a/vs_proj/librf.vcxproj.filters +++ b/vs_proj/librf.vcxproj.filters @@ -133,8 +133,8 @@ tutorial - - tutorial + + benchmark