update boost
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// detail/handler_alloc_helpers.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <boost/asio/detail/memory.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/recycling_allocator.hpp>
|
||||
#include <boost/asio/detail/thread_info_base.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
|
||||
@@ -29,12 +30,45 @@
|
||||
// boost_asio_handler_alloc_helpers namespace is defined here for that purpose.
|
||||
namespace boost_asio_handler_alloc_helpers {
|
||||
|
||||
#if defined(BOOST_ASIO_NO_DEPRECATED)
|
||||
template <typename Handler>
|
||||
inline void* allocate(std::size_t s, Handler& h)
|
||||
inline void error_if_hooks_are_defined(Handler& h)
|
||||
{
|
||||
using boost::asio::asio_handler_allocate;
|
||||
// If you get an error here it is because some of your handlers still
|
||||
// overload asio_handler_allocate, but this hook is no longer used.
|
||||
(void)static_cast<boost::asio::asio_handler_allocate_is_no_longer_used>(
|
||||
asio_handler_allocate(static_cast<std::size_t>(0),
|
||||
boost::asio::detail::addressof(h)));
|
||||
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
// If you get an error here it is because some of your handlers still
|
||||
// overload asio_handler_deallocate, but this hook is no longer used.
|
||||
(void)static_cast<boost::asio::asio_handler_deallocate_is_no_longer_used>(
|
||||
asio_handler_deallocate(static_cast<void*>(0),
|
||||
static_cast<std::size_t>(0), boost::asio::detail::addressof(h)));
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_NO_DEPRECATED)
|
||||
|
||||
template <typename Handler>
|
||||
inline void* allocate(std::size_t s, Handler& h,
|
||||
std::size_t align = BOOST_ASIO_DEFAULT_ALIGN)
|
||||
{
|
||||
#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
|
||||
return ::operator new(s);
|
||||
return boost::asio::aligned_new(align, s);
|
||||
#elif defined(BOOST_ASIO_NO_DEPRECATED)
|
||||
// The asio_handler_allocate hook is no longer used to obtain memory.
|
||||
(void)&error_if_hooks_are_defined<Handler>;
|
||||
(void)h;
|
||||
# if !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
return boost::asio::detail::thread_info_base::allocate(
|
||||
boost::asio::detail::thread_context::top_of_thread_call_stack(),
|
||||
s, align);
|
||||
# else // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
return boost::asio::aligned_new(align, s);
|
||||
# endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
#else
|
||||
(void)align;
|
||||
using boost::asio::asio_handler_allocate;
|
||||
return asio_handler_allocate(s, boost::asio::detail::addressof(h));
|
||||
#endif
|
||||
@@ -44,7 +78,18 @@ template <typename Handler>
|
||||
inline void deallocate(void* p, std::size_t s, Handler& h)
|
||||
{
|
||||
#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
|
||||
::operator delete(p);
|
||||
boost::asio::aligned_delete(p);
|
||||
#elif defined(BOOST_ASIO_NO_DEPRECATED)
|
||||
// The asio_handler_allocate hook is no longer used to obtain memory.
|
||||
(void)&error_if_hooks_are_defined<Handler>;
|
||||
(void)h;
|
||||
#if !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
boost::asio::detail::thread_info_base::deallocate(
|
||||
boost::asio::detail::thread_context::top_of_thread_call_stack(), p, s);
|
||||
#else // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
(void)s;
|
||||
boost::asio::aligned_delete(p);
|
||||
#endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
|
||||
#else
|
||||
using boost::asio::asio_handler_deallocate;
|
||||
asio_handler_deallocate(p, s, boost::asio::detail::addressof(h));
|
||||
@@ -83,7 +128,8 @@ public:
|
||||
T* allocate(std::size_t n)
|
||||
{
|
||||
return static_cast<T*>(
|
||||
boost_asio_handler_alloc_helpers::allocate(sizeof(T) * n, handler_));
|
||||
boost_asio_handler_alloc_helpers::allocate(
|
||||
sizeof(T) * n, handler_, BOOST_ASIO_ALIGNOF(T)));
|
||||
}
|
||||
|
||||
void deallocate(T* p, std::size_t n)
|
||||
|
||||
Reference in New Issue
Block a user