aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/asio/asio_async_base.h
diff options
context:
space:
mode:
authorTim Oesterreich <[email protected]>2019-02-27 14:14:02 +0100
committerHannes Rantzsch <[email protected]>2019-04-16 10:48:03 +0200
commit4835d9476e7f937d6453b1416e6b8c534edec81a (patch)
treeb1225cde114470fc3a6e85359b693090ac079ee7 /src/lib/tls/asio/asio_async_base.h
parente77d10a892a834e3004ce7771eea41b57c534c4d (diff)
review: use asio stackless coroutines instead of expensive template instantiations
Diffstat (limited to 'src/lib/tls/asio/asio_async_base.h')
-rw-r--r--src/lib/tls/asio/asio_async_base.h21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/lib/tls/asio/asio_async_base.h b/src/lib/tls/asio/asio_async_base.h
index f476f7155..e970663bd 100644
--- a/src/lib/tls/asio/asio_async_base.h
+++ b/src/lib/tls/asio/asio_async_base.h
@@ -11,6 +11,7 @@
#include <boost/beast/core/bind_handler.hpp>
+#include <boost/asio/coroutine.hpp>
#include <botan/internal/asio_includes.h>
namespace Botan {
@@ -18,7 +19,7 @@ namespace Botan {
namespace TLS {
template <class Handler, class Executor1, class Allocator>
-struct AsyncBase
+struct AsyncBase : boost::asio::coroutine
{
using allocator_type = boost::asio::associated_allocator_t<Handler, Allocator>;
using executor_type = boost::asio::associated_executor_t<Handler, Executor1>;
@@ -42,22 +43,10 @@ struct AsyncBase
}
template<class... Args>
- void invoke(bool isContinuation, Args&& ... args)
+ void invoke_now(Args&& ... args)
{
- if(!isContinuation)
- {
- // \note(toesterreich): Is this ok to do with bind_handler? Do we need placeholders?
- boost::asio::post(boost::asio::bind_executor(
- m_work_guard_1.get_executor(), boost::beast::bind_handler(std::move(m_handler), args...))
- );
-
- m_work_guard_1.reset();
- }
- else
- {
- m_handler(std::forward<Args>(args)...);
- m_work_guard_1.reset();
- }
+ m_handler(std::forward<Args>(args)...);
+ m_work_guard_1.reset();
}
Handler m_handler;