2
// handler_alloc_hook.hpp
3
// ~~~~~~~~~~~~~~~~~~~~~~
5
// Copyright (c) 2003-2007 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 ASIO_HANDLER_ALLOC_HOOK_HPP
12
#define ASIO_HANDLER_ALLOC_HOOK_HPP
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
#include "asio/detail/push_options.hpp"
20
#include "asio/detail/push_options.hpp"
22
#include <boost/config.hpp>
23
#include "asio/detail/pop_options.hpp"
27
/// Default allocation function for handlers.
29
* Asynchronous operations may need to allocate temporary objects. Since
30
* asynchronous operations have a handler function object, these temporary
31
* objects can be said to be associated with the handler.
33
* Implement asio_handler_allocate and asio_handler_deallocate for your own
34
* handlers to provide custom allocation for these temporary objects.
36
* This default implementation is simply:
38
* return ::operator new(bytes);
41
* @note All temporary objects associated with a handler will be deallocated
42
* before the upcall to the handler is performed. This allows the same memory to
43
* be reused for a subsequent asynchronous operation initiated by the handler.
49
* void* asio_handler_allocate(std::size_t size, my_handler* context)
51
* return ::operator new(size);
54
* void asio_handler_deallocate(void* pointer, std::size_t size,
55
* my_handler* context)
57
* ::operator delete(pointer);
61
inline void* asio_handler_allocate(std::size_t size, ...)
63
return ::operator new(size);
66
/// Default deallocation function for handlers.
68
* Implement asio_handler_allocate and asio_handler_deallocate for your own
69
* handlers to provide custom allocation for the associated temporary objects.
71
* This default implementation is simply:
73
* ::operator delete(pointer);
76
* @sa asio_handler_allocate.
78
inline void asio_handler_deallocate(void* pointer, std::size_t size, ...)
81
::operator delete(pointer);
86
#include "asio/detail/pop_options.hpp"
88
#endif // ASIO_HANDLER_ALLOC_HOOK_HPP