]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/handler_alloc_hook.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / asio / handler_alloc_hook.hpp
1 //
2 // handler_alloc_hook.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10
11 #ifndef BOOST_ASIO_HANDLER_ALLOC_HOOK_HPP
12 #define BOOST_ASIO_HANDLER_ALLOC_HOOK_HPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19 #include <cstddef>
20
21 #include <boost/asio/detail/push_options.hpp>
22
23 namespace boost {
24 namespace asio {
25
26 #if defined(BOOST_ASIO_NO_DEPRECATED)
27
28 // Places in asio that would have previously called the allocate or deallocate
29 // hooks to manage memory, now call them only to check whether the result types
30 // are these types. If the result is not the correct type, it indicates that
31 // the user code still has the old hooks in place, and if so we want to trigger
32 // a compile error.
33 enum asio_handler_allocate_is_no_longer_used {};
34 enum asio_handler_deallocate_is_no_longer_used {};
35
36 typedef asio_handler_allocate_is_no_longer_used
37 asio_handler_allocate_is_deprecated;
38 typedef asio_handler_deallocate_is_no_longer_used
39 asio_handler_deallocate_is_deprecated;
40
41 #else // defined(BOOST_ASIO_NO_DEPRECATED)
42
43 typedef void* asio_handler_allocate_is_deprecated;
44 typedef void asio_handler_deallocate_is_deprecated;
45
46 #endif // defined(BOOST_ASIO_NO_DEPRECATED)
47
48 /// (Deprecated: Use the associated_allocator trait.) Default allocation
49 /// function for handlers.
50 /**
51 * Asynchronous operations may need to allocate temporary objects. Since
52 * asynchronous operations have a handler function object, these temporary
53 * objects can be said to be associated with the handler.
54 *
55 * Implement asio_handler_allocate and asio_handler_deallocate for your own
56 * handlers to provide custom allocation for these temporary objects.
57 *
58 * The default implementation of these allocation hooks uses <tt>::operator
59 * new</tt> and <tt>::operator delete</tt>.
60 *
61 * @note All temporary objects associated with a handler will be deallocated
62 * before the upcall to the handler is performed. This allows the same memory to
63 * be reused for a subsequent asynchronous operation initiated by the handler.
64 *
65 * @par Example
66 * @code
67 * class my_handler;
68 *
69 * void* asio_handler_allocate(std::size_t size, my_handler* context)
70 * {
71 * return ::operator new(size);
72 * }
73 *
74 * void asio_handler_deallocate(void* pointer, std::size_t size,
75 * my_handler* context)
76 * {
77 * ::operator delete(pointer);
78 * }
79 * @endcode
80 */
81 BOOST_ASIO_DECL asio_handler_allocate_is_deprecated
82 asio_handler_allocate(std::size_t size, ...);
83
84 /// Default deallocation function for handlers.
85 /**
86 * Implement asio_handler_allocate and asio_handler_deallocate for your own
87 * handlers to provide custom allocation for the associated temporary objects.
88 *
89 * The default implementation of these allocation hooks uses <tt>::operator
90 * new</tt> and <tt>::operator delete</tt>.
91 *
92 * @sa asio_handler_allocate.
93 */
94 BOOST_ASIO_DECL asio_handler_deallocate_is_deprecated
95 asio_handler_deallocate(void* pointer, std::size_t size, ...);
96
97 } // namespace asio
98 } // namespace boost
99
100 #include <boost/asio/detail/pop_options.hpp>
101
102 #if defined(BOOST_ASIO_HEADER_ONLY)
103 # include <boost/asio/impl/handler_alloc_hook.ipp>
104 #endif // defined(BOOST_ASIO_HEADER_ONLY)
105
106 #endif // BOOST_ASIO_HANDLER_ALLOC_HOOK_HPP