@@ -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; |
@@ -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(); |
@@ -83,6 +83,7 @@ static future_t<std::string&> resumable_get_string(std::string& val) | |||
void resumable_main_cb() | |||
{ | |||
std::cout << __FUNCTION__ << std::endl; | |||
//由于使用者可能不能明确的区分是resume function返回的awaitor还是awaitable function返回的awaitor | |||
//导致均有可能加入到协程里去调度。 | |||
//所以,协程调度器应该需要能处理这种情况。 |
@@ -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(); | |||
} | |||
} |
@@ -151,6 +151,7 @@ static void example_librf() | |||
void resumable_main_modern_cb() | |||
{ | |||
std::cout << __FUNCTION__ << std::endl; | |||
example_future(); | |||
example_librf(); | |||
} |
@@ -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); |
@@ -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(); |
@@ -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(); |
@@ -73,6 +73,7 @@ auto test_yield_future() -> future_t<int64_t> | |||
void resumable_main_yield_return() | |||
{ | |||
std::cout << __FUNCTION__ << std::endl; | |||
for (int i : test_yield_int()) | |||
{ | |||
std::cout << i << " had return" << std::endl; |