handler_ptr is deprecated (API Change):

* `handler_ptr` is deprecated and should not be used.

Actions Required:

* Replace use of `handler_ptr` with `stable_async_base`
  and `allocate_stable`.
This commit is contained in:
Vinnie Falco
2019-03-06 08:09:35 -08:00
parent 7f53b0f66c
commit 45353a7f04
27 changed files with 95 additions and 64 deletions

View File

@ -4,6 +4,15 @@ Version 229:
* Tidy up examples
* detect_ssl returns a bool
API Changes:
* handler_ptr is deprecated
Actions Required:
* Replace use of `handler_ptr` with `stable_async_base`
and `allocate_stable`.
--------------------------------------------------------------------------------
Version 228:

View File

@ -197,6 +197,11 @@
in a future version. ['Actions Required]: Do not rely on
the ['Fields] concept.
* `handler_ptr` is deprecated. ['Actions Required]: Use
`stable_async_base` and
`allocate_stable`
instead.
* On Windows, Visual Studio 2017 or later is required
* OpenSSL is required to build the examples and tests

View File

@ -304,7 +304,7 @@ async_echo(
// calling the final completion handler, using post if the
// first argument is false, otherwise invoking it directly.
this->invoke(cont, ec);
this->complete(cont, ec);
}
}
};

View File

@ -293,7 +293,7 @@ public:
}
}
upcall:
this->invoke_now(ec, bytes_transferred);
this->complete_now(ec, bytes_transferred);
}
}
};

View File

@ -34,7 +34,6 @@
#include <boost/beast/core/flat_buffer.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/core/flat_stream.hpp>
#include <boost/beast/core/handler_ptr.hpp>
#include <boost/beast/core/make_printable.hpp>
#include <boost/beast/core/multi_buffer.hpp>
#include <boost/beast/core/ostream.hpp>

View File

@ -317,7 +317,7 @@ public:
This invokes the final completion handler with the specified
arguments forwarded. It is undefined to call either of
@ref invoke or @ref invoke_now more than once.
@ref complete or @ref complete_now more than once.
Any temporary objects allocated with @ref beast::allocate_stable will
be automatically destroyed before the final completion handler
@ -326,7 +326,7 @@ public:
@param is_continuation If this value is `false`, then the
handler will be submitted to the executor using `net::post`.
Otherwise the handler will be invoked as if by calling
@ref invoke_now.
@ref complete_now.
@param args A list of optional parameters to invoke the handler
with. The completion handler must be invocable with the parameter
@ -334,7 +334,7 @@ public:
*/
template<class... Args>
void
invoke(bool is_continuation, Args&&... args)
complete(bool is_continuation, Args&&... args)
{
this->before_invoke_hook();
if(! is_continuation)
@ -357,7 +357,7 @@ public:
This invokes the final completion handler with the specified
arguments forwarded. It is undefined to call either of
@ref invoke or @ref invoke_now more than once.
@ref complete or @ref complete_now more than once.
Any temporary objects allocated with @ref beast::allocate_stable will
be automatically destroyed before the final completion handler
@ -369,7 +369,7 @@ public:
*/
template<class... Args>
void
invoke_now(Args&&... args)
complete_now(Args&&... args)
{
this->before_invoke_hook();
wg1_.reset();
@ -532,7 +532,7 @@ public:
}
// The base class destroys the temporary data automatically, before invoking the final completion handler
this->invoke_now(ec);
this->complete_now(ec);
}
};

View File

@ -103,7 +103,7 @@ public:
b_.prepare(0), std::move(*this));
ec = ec_;
}
this->invoke_now(ec, total_);
this->complete_now(ec, total_);
}
}
};

View File

@ -626,7 +626,7 @@ operator()(error_code ec, std::size_t bytes_transferred, bool cont)
// At this point, we are guaranteed that the original initiating
// function is no longer on our stack frame.
this->invoke_now(ec, static_cast<bool>(result_));
this->complete_now(ec, static_cast<bool>(result_));
}
}

View File

@ -13,9 +13,14 @@
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/detail/allocator.hpp>
#include <boost/assert.hpp>
#include <boost/config/pragma_message.hpp>
#include <type_traits>
#include <utility>
#ifndef BOOST_BEAST_DOXYGEN
BOOST_PRAGMA_MESSAGE("<boost/beast/core/handler_ptr.hpp> is DEPRECATED and will be removed in a future release.")
namespace boost {
namespace beast {
@ -49,6 +54,11 @@ namespace beast {
template<class T, class Handler>
class handler_ptr
{
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(T) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
T* t_ = nullptr;
union
{
@ -215,3 +225,5 @@ public:
#include <boost/beast/core/impl/handler_ptr.hpp>
#endif
#endif

View File

@ -397,7 +397,7 @@ public:
upcall:
pg_.reset();
transfer_bytes(bytes_transferred);
this->invoke_now(ec, bytes_transferred);
this->complete_now(ec, bytes_transferred);
}
}
};
@ -528,7 +528,7 @@ public:
pg0_.reset();
pg1_.reset();
this->invoke_now(ec, std::forward<Args>(args)...);
this->complete_now(ec, std::forward<Args>(args)...);
}
};

View File

@ -99,7 +99,7 @@ public:
s_.buffer_.consume(bytes_transferred);
break;
}
this->invoke_now(ec, bytes_transferred);
this->complete_now(ec, bytes_transferred);
}
};

View File

@ -71,7 +71,7 @@ public:
boost::system::error_code ec,
std::size_t bytes_transferred)
{
this->invoke_now(ec, bytes_transferred);
this->complete_now(ec, bytes_transferred);
}
};

View File

@ -12,14 +12,13 @@
#ifndef BOOST_BEAST_DOXYGEN
BOOST_PRAGMA_MESSAGE("<boost/beast/core/type_traits.hpp> is DEPRECATED and will be removed in a future release.")
#include <boost/beast/core/file_base.hpp>
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/detail/is_invocable.hpp>
#include <boost/config/pragma_message.hpp>
#include <type_traits.hpp>
BOOST_PRAGMA_MESSAGE("<boost/beast/core/type_traits.hpp> is DEPRECATED and will be removed in a future release.")
namespace boost {
namespace beast {

View File

@ -430,7 +430,7 @@ public:
BOOST_ASSERT(sr_.is_done());
}
}
this->invoke_now(ec, bytes_transferred_);
this->complete_now(ec, bytes_transferred_);
}
};

View File

@ -209,7 +209,7 @@ public:
{
if(! ec)
d_.m = d_.p.release();
this->invoke_now(ec, bytes_transferred);
this->complete_now(ec, bytes_transferred);
}
};

View File

@ -119,7 +119,7 @@ public:
{
if(! ec)
sr_.consume(bytes_transferred);
this->invoke_now(ec, bytes_transferred);
this->complete_now(ec, bytes_transferred);
}
};
@ -207,7 +207,7 @@ public:
break;
}
upcall:
this->invoke_now(ec, bytes_transferred_);
this->complete_now(ec, bytes_transferred_);
}
}
};
@ -254,7 +254,7 @@ public:
operator()(
error_code ec, std::size_t bytes_transferred)
{
this->invoke_now(ec, bytes_transferred);
this->complete_now(ec, bytes_transferred);
}
};

View File

@ -209,7 +209,7 @@ public:
boost::ignore_unused(bytes_transferred);
auto sp = wp_.lock();
if(! sp)
return this->invoke(cont,
return this->complete(cont,
net::error::operation_aborted);
auto& impl = *sp;
BOOST_ASIO_CORO_REENTER(*this)
@ -231,7 +231,7 @@ public:
impl.open(role_type::server);
}
upcall:
this->invoke(cont, ec);
this->complete(cont, ec);
}
}
};
@ -287,7 +287,7 @@ public:
boost::ignore_unused(bytes_transferred);
auto sp = wp_.lock();
if(! sp)
return this->invoke(cont,
return this->complete(cont,
net::error::operation_aborted);
auto& impl = *sp;
BOOST_ASIO_CORO_REENTER(*this)
@ -320,7 +320,7 @@ public:
}
upcall:
this->invoke(cont, ec);
this->complete(cont, ec);
}
}
};
@ -709,7 +709,7 @@ void
stream<NextLayer, deflateSupported>::
accept_ex(ResponseDecorator const& decorator)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(ResponseDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -730,7 +730,7 @@ void
stream<NextLayer, deflateSupported>::
accept_ex(ResponseDecorator const& decorator, error_code& ec)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(ResponseDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -755,7 +755,7 @@ accept_ex(
ConstBufferSequence const& buffers,
ResponseDecorator const &decorator)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(ResponseDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -785,7 +785,7 @@ accept_ex(
ResponseDecorator const& decorator,
error_code& ec)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(ResponseDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -811,7 +811,7 @@ accept_ex(
http::basic_fields<Allocator>> const& req,
ResponseDecorator const& decorator)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(ResponseDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -838,7 +838,7 @@ accept_ex(
ResponseDecorator const& decorator,
error_code& ec)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(ResponseDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif

View File

@ -75,7 +75,7 @@ public:
using beast::detail::clamp;
auto sp = wp_.lock();
if(! sp)
return this->invoke(cont,
return this->complete(cont,
net::error::operation_aborted);
auto& impl = *sp;
BOOST_ASIO_CORO_REENTER(*this)
@ -225,7 +225,7 @@ public:
|| impl.op_idle_ping.maybe_invoke()
|| impl.op_ping.maybe_invoke()
|| impl.op_wr.maybe_invoke();
this->invoke(cont, ec);
this->complete(cont, ec);
}
}
};

View File

@ -92,7 +92,7 @@ public:
boost::ignore_unused(bytes_used);
auto sp = wp_.lock();
if(! sp)
return this->invoke(cont,
return this->complete(cont,
net::error::operation_aborted);
auto& impl = *sp;
BOOST_ASIO_CORO_REENTER(*this)
@ -159,7 +159,7 @@ public:
swap(d_.p.get(), *res_p_);
upcall:
this->invoke(cont ,ec);
this->complete(cont ,ec);
}
}
};
@ -382,7 +382,7 @@ handshake_ex(string_view host,
string_view target,
RequestDecorator const& decorator)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(RequestDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -406,7 +406,7 @@ handshake_ex(response_type& res,
string_view target,
RequestDecorator const& decorator)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(RequestDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -430,7 +430,7 @@ handshake_ex(string_view host,
RequestDecorator const& decorator,
error_code& ec)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(RequestDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -453,7 +453,7 @@ handshake_ex(response_type& res,
RequestDecorator const& decorator,
error_code& ec)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(RequestDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -475,7 +475,7 @@ async_handshake_ex(string_view host,
RequestDecorator const& decorator,
HandshakeHandler&& handler)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(RequestDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif
@ -508,7 +508,7 @@ async_handshake_ex(response_type& res,
RequestDecorator const& decorator,
HandshakeHandler&& handler)
{
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
static_assert(sizeof(RequestDecorator) == 0,
BOOST_BEAST_DEPRECATION_STRING);
#endif

View File

@ -71,7 +71,7 @@ public:
boost::ignore_unused(bytes_transferred);
auto sp = wp_.lock();
if(! sp)
return this->invoke(cont,
return this->complete(cont,
net::error::operation_aborted);
auto& impl = *sp;
BOOST_ASIO_CORO_REENTER(*this)
@ -102,7 +102,7 @@ public:
|| impl.op_idle_ping.maybe_invoke()
|| impl.op_rd.maybe_invoke()
|| impl.op_wr.maybe_invoke();
this->invoke(cont, ec);
this->complete(cont, ec);
}
}
};

View File

@ -85,7 +85,7 @@ public:
using beast::detail::clamp;
auto sp = wp_.lock();
if(! sp)
return this->invoke(cont,
return this->complete(cont,
net::error::operation_aborted, 0);
auto& impl = *sp;
BOOST_ASIO_CORO_REENTER(*this)
@ -603,7 +603,7 @@ public:
|| impl.op_idle_ping.maybe_invoke()
|| impl.op_ping.maybe_invoke()
|| impl.op_wr.maybe_invoke();
this->invoke(cont, ec, bytes_written_);
this->complete(cont, ec, bytes_written_);
}
}
};
@ -652,7 +652,7 @@ public:
using beast::detail::clamp;
auto sp = wp_.lock();
if(! sp)
return this->invoke(cont,
return this->complete(cont,
net::error::operation_aborted, 0);
auto& impl = *sp;
using mutable_buffers_type = typename
@ -680,7 +680,7 @@ public:
while(! some_ && ! impl.rd_done);
upcall:
this->invoke(cont, ec, bytes_written_);
this->complete(cont, ec, bytes_written_);
}
}
};

View File

@ -120,7 +120,7 @@ public:
error_code ignored;
s_.non_blocking(nb_, ignored);
}
this->invoke_now(ec);
this->complete_now(ec);
}
}
};

View File

@ -161,7 +161,7 @@ operator()(
net::mutable_buffer b;
auto sp = wp_.lock();
if(! sp)
return this->invoke(cont,
return this->complete(cont,
net::error::operation_aborted, 0);
auto& impl = *sp;
BOOST_ASIO_CORO_REENTER(*this)
@ -426,7 +426,7 @@ operator()(
|| impl.op_idle_ping.maybe_invoke()
|| impl.op_rd.maybe_invoke()
|| impl.op_ping.maybe_invoke();
this->invoke(cont, ec, bytes_transferred_);
this->complete(cont, ec, bytes_transferred_);
}
}

View File

@ -12,7 +12,7 @@
#include <boost/beast/core/detail/config.hpp>
#if ! BOOST_BEAST_ALLOW_DEPRECATED
#ifndef BOOST_BEAST_ALLOW_DEPRECATED
#error This file is deprecated interface, #define BOOST_BEAST_ALLOW_DEPRECATED to allow it

View File

@ -425,7 +425,7 @@ public:
test::handler,
net::io_context::executor_type> op(
test::any_handler(), ioc.get_executor());
op.invoke(true);
op.complete(true);
}
{
net::io_context ioc;
@ -433,7 +433,7 @@ public:
test::handler,
net::io_context::executor_type> op(
test::any_handler(), ioc.get_executor());
op.invoke(false);
op.complete(false);
ioc.run();
}
{
@ -441,7 +441,7 @@ public:
test::handler,
simple_executor> op(
test::any_handler(), {});
op.invoke_now();
op.complete_now();
}
// legacy hooks
@ -499,7 +499,7 @@ public:
test::handler,
net::io_context::executor_type> op(
test::any_handler(), ioc.get_executor());
op.invoke(true);
op.complete(true);
}
{
net::io_context ioc;
@ -507,7 +507,7 @@ public:
test::handler,
net::io_context::executor_type> op(
test::any_handler(), ioc.get_executor());
op.invoke(false);
op.complete(false);
ioc.run();
}
{
@ -515,7 +515,7 @@ public:
test::handler,
simple_executor> op(
test::any_handler(), {});
op.invoke_now();
op.complete_now();
}
// legacy hooks
@ -620,7 +620,7 @@ public:
// `net::post` will be used to call the completion handler, otherwise
// the completion handler will be invoked directly.
this->invoke(is_continuation, ec, total_bytes_transferred_);
this->complete(is_continuation, ec, total_bytes_transferred_);
}
};
@ -707,7 +707,7 @@ public:
}
// The base class destroys the temporary data automatically, before invoking the final completion handler
this->invoke_now(ec);
this->complete_now(ec);
}
};

View File

@ -7,6 +7,11 @@
// Official repository: https://github.com/boostorg/beast
//
#ifdef BOOST_BEAST_ALLOW_DEPRECATED
#undef BOOST_BEAST_ALLOW_DEPRECATED
#define BOOST_BEAST_ALLOW_DEPRECATED 0
#endif
// Test that header file is self-contained.
#include <boost/beast/core/handler_ptr.hpp>
@ -121,3 +126,5 @@ BEAST_DEFINE_TESTSUITE(beast,core,handler_ptr);
} // beast
} // boost
#undef BOOST_BEAST_ALLOW_DEPRECATED

View File

@ -110,7 +110,7 @@ class counted_stream
// Count the bytes transferred towards the total
stream_.bytes_read_ += bytes_transferred;
this->invoke_now(ec, bytes_transferred);
this->complete_now(ec, bytes_transferred);
}
};
@ -156,7 +156,7 @@ class counted_stream
// Count the bytes transferred towards the total
stream_.bytes_written_ += bytes_transferred;
this->invoke_now(ec, bytes_transferred);
this->complete_now(ec, bytes_transferred);
}
};