examples & tests use context instead of coroutine.

This commit is contained in:
Klemens
2023-02-02 23:27:49 +08:00
committed by Klemens Morgenstern
parent 1841a592d6
commit 99bceb5bff
24 changed files with 156 additions and 37 deletions
+1 -1
View File
@@ -19,5 +19,5 @@ exe http-client-coro-ssl :
:
<variant>coverage:<build>no
<variant>ubasan:<build>no
<library>/boost/coroutine//boost_coroutine
<library>/boost/context//boost_context
;
@@ -163,14 +163,25 @@ int main(int argc, char** argv)
// Launch the asynchronous operation
boost::asio::spawn(ioc, std::bind(
&do_session,
std::string(host),
std::string(port),
std::string(target),
version,
std::ref(ioc),
std::ref(ctx),
std::placeholders::_1));
&do_session,
std::string(host),
std::string(port),
std::string(target),
version,
std::ref(ioc),
std::ref(ctx),
std::placeholders::_1),
// on completion, spawn will call this function
[](std::exception_ptr ex)
{
// if an exception occurred in the coroutine,
// it's something critical, e.g. out of memory
// we capture normal errors in the ec
// so we just rethrow the exception here,
// which will cause `ioc.run()` to throw
if (ex)
std::rethrow_exception(ex);
});
// Run the I/O service. The call will return when
// the get operation is complete.
+1 -1
View File
@@ -12,5 +12,5 @@ exe http-client-coro :
:
<variant>coverage:<build>no
<variant>ubasan:<build>no
<library>/boost/coroutine//boost_coroutine
<library>/boost/context//boost_context
;
+12 -1
View File
@@ -134,7 +134,18 @@ int main(int argc, char** argv)
std::string(target),
version,
std::ref(ioc),
std::placeholders::_1));
std::placeholders::_1),
// on completion, spawn will call this function
[](std::exception_ptr ex)
{
// if an exception occurred in the coroutine,
// it's something critical, e.g. out of memory
// we capture normal errors in the ec
// so we just rethrow the exception here,
// which will cause `ioc.run()` to throw
if (ex)
std::rethrow_exception(ex);
});
// Run the I/O service. The call will return when
// the get operation is complete.