]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/include/boost/asio/impl/handler_alloc_hook.ipp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / asio / include / boost / asio / impl / handler_alloc_hook.ipp
1 //
2 // impl/handler_alloc_hook.ipp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2016 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_IMPL_HANDLER_ALLOC_HOOK_IPP
12 #define BOOST_ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP
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 <boost/asio/detail/call_stack.hpp>
20 #include <boost/asio/handler_alloc_hook.hpp>
21
22 #if !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
23 # if defined(BOOST_ASIO_HAS_IOCP)
24 # include <boost/asio/detail/win_iocp_thread_info.hpp>
25 # else // defined(BOOST_ASIO_HAS_IOCP)
26 # include <boost/asio/detail/task_io_service_thread_info.hpp>
27 # endif // defined(BOOST_ASIO_HAS_IOCP)
28 #endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
29
30 #include <boost/asio/detail/push_options.hpp>
31
32 namespace boost {
33 namespace asio {
34
35 #if defined(BOOST_ASIO_HAS_IOCP)
36 namespace detail { class win_iocp_io_service; }
37 #endif // defined(BOOST_ASIO_HAS_IOCP)
38
39 void* asio_handler_allocate(std::size_t size, ...)
40 {
41 #if !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
42 # if defined(BOOST_ASIO_HAS_IOCP)
43 typedef detail::win_iocp_io_service io_service_impl;
44 typedef detail::win_iocp_thread_info thread_info;
45 # else // defined(BOOST_ASIO_HAS_IOCP)
46 typedef detail::task_io_service io_service_impl;
47 typedef detail::task_io_service_thread_info thread_info;
48 # endif // defined(BOOST_ASIO_HAS_IOCP)
49 typedef detail::call_stack<io_service_impl, thread_info> call_stack;
50 return thread_info::allocate(call_stack::top(), size);
51 #else // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
52 return ::operator new(size);
53 #endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
54 }
55
56 void asio_handler_deallocate(void* pointer, std::size_t size, ...)
57 {
58 #if !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
59 # if defined(BOOST_ASIO_HAS_IOCP)
60 typedef detail::win_iocp_io_service io_service_impl;
61 typedef detail::win_iocp_thread_info thread_info;
62 # else // defined(BOOST_ASIO_HAS_IOCP)
63 typedef detail::task_io_service io_service_impl;
64 typedef detail::task_io_service_thread_info thread_info;
65 # endif // defined(BOOST_ASIO_HAS_IOCP)
66 typedef detail::call_stack<io_service_impl, thread_info> call_stack;
67 thread_info::deallocate(call_stack::top(), pointer, size);
68 #else // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
69 (void)size;
70 ::operator delete(pointer);
71 #endif // !defined(BOOST_ASIO_DISABLE_SMALL_BLOCK_RECYCLING)
72 }
73
74 } // namespace asio
75 } // namespace boost
76
77 #include <boost/asio/detail/pop_options.hpp>
78
79 #endif // BOOST_ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP