2 // impl/cancellation_signal.ipp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_IMPL_CANCELLATION_SIGNAL_IPP
12 #define BOOST_ASIO_IMPL_CANCELLATION_SIGNAL_IPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/cancellation_signal.hpp>
20 #include <boost/asio/detail/thread_context.hpp>
21 #include <boost/asio/detail/thread_info_base.hpp>
23 #include <boost/asio/detail/push_options.hpp>
28 cancellation_signal::~cancellation_signal()
32 std::pair<void*, std::size_t> mem = handler_->destroy();
33 detail::thread_info_base::deallocate(
34 detail::thread_info_base::cancellation_signal_tag(),
35 detail::thread_context::top_of_thread_call_stack(),
36 mem.first, mem.second);
40 void cancellation_slot::clear()
42 if (handler_ != 0 && *handler_ != 0)
44 std::pair<void*, std::size_t> mem = (*handler_)->destroy();
45 detail::thread_info_base::deallocate(
46 detail::thread_info_base::cancellation_signal_tag(),
47 detail::thread_context::top_of_thread_call_stack(),
48 mem.first, mem.second);
53 std::pair<void*, std::size_t> cancellation_slot::prepare_memory(
54 std::size_t size, std::size_t align)
57 std::pair<void*, std::size_t> mem;
60 mem = (*handler_)->destroy();
64 || reinterpret_cast<std::size_t>(mem.first) % align != 0)
68 detail::thread_info_base::deallocate(
69 detail::thread_info_base::cancellation_signal_tag(),
70 detail::thread_context::top_of_thread_call_stack(),
71 mem.first, mem.second);
73 mem.first = detail::thread_info_base::allocate(
74 detail::thread_info_base::cancellation_signal_tag(),
75 detail::thread_context::top_of_thread_call_stack(),
82 cancellation_slot::auto_delete_helper::~auto_delete_helper()
86 detail::thread_info_base::deallocate(
87 detail::thread_info_base::cancellation_signal_tag(),
88 detail::thread_context::top_of_thread_call_stack(),
89 mem.first, mem.second);
96 #include <boost/asio/detail/pop_options.hpp>
98 #endif // BOOST_ASIO_IMPL_CANCELLATION_SIGNAL_IPP