forked from boostorg/beast
Remove the use of bind_executor
in basic_stream
:
Use the executor hook instead of `bind_executor` to avoid template instantiations. Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
@@ -284,6 +284,7 @@ private:
|
|||||||
// but the implementation is still waiting on a timer.
|
// but the implementation is still waiting on a timer.
|
||||||
boost::shared_ptr<impl_type> impl_;
|
boost::shared_ptr<impl_type> impl_;
|
||||||
|
|
||||||
|
template<class Executor2>
|
||||||
struct timeout_handler;
|
struct timeout_handler;
|
||||||
|
|
||||||
struct ops;
|
struct ops;
|
||||||
|
@@ -15,7 +15,6 @@
|
|||||||
#include <boost/beast/core/buffers_prefix.hpp>
|
#include <boost/beast/core/buffers_prefix.hpp>
|
||||||
#include <boost/beast/core/detail/type_traits.hpp>
|
#include <boost/beast/core/detail/type_traits.hpp>
|
||||||
#include <boost/beast/websocket/teardown.hpp>
|
#include <boost/beast/websocket/teardown.hpp>
|
||||||
#include <boost/asio/bind_executor.hpp>
|
|
||||||
#include <boost/asio/coroutine.hpp>
|
#include <boost/asio/coroutine.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
@@ -161,12 +160,21 @@ close()
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
template<class Protocol, class Executor, class RatePolicy>
|
template<class Protocol, class Executor, class RatePolicy>
|
||||||
|
template<class Executor2>
|
||||||
struct basic_stream<Protocol, Executor, RatePolicy>::
|
struct basic_stream<Protocol, Executor, RatePolicy>::
|
||||||
timeout_handler
|
timeout_handler
|
||||||
{
|
{
|
||||||
|
using executor_type = Executor2;
|
||||||
|
|
||||||
op_state& state;
|
op_state& state;
|
||||||
boost::weak_ptr<impl_type> wp;
|
boost::weak_ptr<impl_type> wp;
|
||||||
tick_type tick;
|
tick_type tick;
|
||||||
|
executor_type ex;
|
||||||
|
|
||||||
|
executor_type get_executor() const noexcept
|
||||||
|
{
|
||||||
|
return ex;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
operator()(error_code ec)
|
operator()(error_code ec)
|
||||||
@@ -329,13 +337,11 @@ public:
|
|||||||
// if a timeout is active, wait on the timer
|
// if a timeout is active, wait on the timer
|
||||||
if(state().timer.expiry() != never())
|
if(state().timer.expiry() != never())
|
||||||
state().timer.async_wait(
|
state().timer.async_wait(
|
||||||
net::bind_executor(
|
timeout_handler<decltype(this->get_executor())>{
|
||||||
this->get_executor(),
|
state(),
|
||||||
timeout_handler{
|
impl_,
|
||||||
state(),
|
state().tick,
|
||||||
impl_,
|
this->get_executor()});
|
||||||
state().tick
|
|
||||||
}));
|
|
||||||
|
|
||||||
// check rate limit, maybe wait
|
// check rate limit, maybe wait
|
||||||
std::size_t amount;
|
std::size_t amount;
|
||||||
@@ -430,12 +436,11 @@ public:
|
|||||||
{
|
{
|
||||||
if(state().timer.expiry() != stream_base::never())
|
if(state().timer.expiry() != stream_base::never())
|
||||||
impl_->write.timer.async_wait(
|
impl_->write.timer.async_wait(
|
||||||
net::bind_executor(
|
timeout_handler<decltype(this->get_executor())>{
|
||||||
this->get_executor(),
|
state(),
|
||||||
timeout_handler{
|
impl_,
|
||||||
state(),
|
state().tick,
|
||||||
impl_,
|
this->get_executor()});
|
||||||
state().tick}));
|
|
||||||
|
|
||||||
impl_->socket.async_connect(
|
impl_->socket.async_connect(
|
||||||
ep, std::move(*this));
|
ep, std::move(*this));
|
||||||
@@ -458,12 +463,11 @@ public:
|
|||||||
{
|
{
|
||||||
if(state().timer.expiry() != stream_base::never())
|
if(state().timer.expiry() != stream_base::never())
|
||||||
impl_->write.timer.async_wait(
|
impl_->write.timer.async_wait(
|
||||||
net::bind_executor(
|
timeout_handler<decltype(this->get_executor())>{
|
||||||
this->get_executor(),
|
state(),
|
||||||
timeout_handler{
|
impl_,
|
||||||
state(),
|
state().tick,
|
||||||
impl_,
|
this->get_executor()});
|
||||||
state().tick}));
|
|
||||||
|
|
||||||
net::async_connect(impl_->socket,
|
net::async_connect(impl_->socket,
|
||||||
eps, cond, std::move(*this));
|
eps, cond, std::move(*this));
|
||||||
@@ -486,12 +490,11 @@ public:
|
|||||||
{
|
{
|
||||||
if(state().timer.expiry() != stream_base::never())
|
if(state().timer.expiry() != stream_base::never())
|
||||||
impl_->write.timer.async_wait(
|
impl_->write.timer.async_wait(
|
||||||
net::bind_executor(
|
timeout_handler<decltype(this->get_executor())>{
|
||||||
this->get_executor(),
|
state(),
|
||||||
timeout_handler{
|
impl_,
|
||||||
state(),
|
state().tick,
|
||||||
impl_,
|
this->get_executor()});
|
||||||
state().tick}));
|
|
||||||
|
|
||||||
net::async_connect(impl_->socket,
|
net::async_connect(impl_->socket,
|
||||||
begin, end, cond, std::move(*this));
|
begin, end, cond, std::move(*this));
|
||||||
|
Reference in New Issue
Block a user