Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.4KB

  1. //
  2. // handler_alloc_hook.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 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. #ifndef ASIO_HANDLER_ALLOC_HOOK_HPP
  11. #define ASIO_HANDLER_ALLOC_HOOK_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include <cstddef>
  17. #include "asio/detail/push_options.hpp"
  18. namespace asio {
  19. /// Default allocation function for handlers.
  20. /**
  21. * Asynchronous operations may need to allocate temporary objects. Since
  22. * asynchronous operations have a handler function object, these temporary
  23. * objects can be said to be associated with the handler.
  24. *
  25. * Implement asio_handler_allocate and asio_handler_deallocate for your own
  26. * handlers to provide custom allocation for these temporary objects.
  27. *
  28. * The default implementation of these allocation hooks uses <tt>::operator
  29. * new</tt> and <tt>::operator delete</tt>.
  30. *
  31. * @note All temporary objects associated with a handler will be deallocated
  32. * before the upcall to the handler is performed. This allows the same memory to
  33. * be reused for a subsequent asynchronous operation initiated by the handler.
  34. *
  35. * @par Example
  36. * @code
  37. * class my_handler;
  38. *
  39. * void* asio_handler_allocate(std::size_t size, my_handler* context)
  40. * {
  41. * return ::operator new(size);
  42. * }
  43. *
  44. * void asio_handler_deallocate(void* pointer, std::size_t size,
  45. * my_handler* context)
  46. * {
  47. * ::operator delete(pointer);
  48. * }
  49. * @endcode
  50. */
  51. ASIO_DECL void* asio_handler_allocate(
  52. std::size_t size, ...);
  53. /// Default deallocation function for handlers.
  54. /**
  55. * Implement asio_handler_allocate and asio_handler_deallocate for your own
  56. * handlers to provide custom allocation for the associated temporary objects.
  57. *
  58. * The default implementation of these allocation hooks uses <tt>::operator
  59. * new</tt> and <tt>::operator delete</tt>.
  60. *
  61. * @sa asio_handler_allocate.
  62. */
  63. ASIO_DECL void asio_handler_deallocate(
  64. void* pointer, std::size_t size, ...);
  65. } // namespace asio
  66. #include "asio/detail/pop_options.hpp"
  67. #if defined(ASIO_HEADER_ONLY)
  68. # include "asio/impl/handler_alloc_hook.ipp"
  69. #endif // defined(ASIO_HEADER_ONLY)
  70. #endif // ASIO_HANDLER_ALLOC_HOOK_HPP