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.

97 lines
2.0KB

  1. //
  2. // detail/win_iocp_operation.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 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_DETAIL_WIN_IOCP_OPERATION_HPP
  11. #define ASIO_DETAIL_WIN_IOCP_OPERATION_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. #if defined(ASIO_HAS_IOCP)
  17. #include "asio/detail/handler_tracking.hpp"
  18. #include "asio/detail/op_queue.hpp"
  19. #include "asio/detail/socket_types.hpp"
  20. #include "asio/error_code.hpp"
  21. #include "asio/detail/push_options.hpp"
  22. namespace asio {
  23. namespace detail {
  24. class win_iocp_io_context;
  25. // Base class for all operations. A function pointer is used instead of virtual
  26. // functions to avoid the associated overhead.
  27. class win_iocp_operation
  28. : public OVERLAPPED
  29. ASIO_ALSO_INHERIT_TRACKED_HANDLER
  30. {
  31. public:
  32. typedef win_iocp_operation operation_type;
  33. void complete(void* owner, const asio::error_code& ec,
  34. std::size_t bytes_transferred)
  35. {
  36. func_(owner, this, ec, bytes_transferred);
  37. }
  38. void destroy()
  39. {
  40. func_(0, this, asio::error_code(), 0);
  41. }
  42. protected:
  43. typedef void (*func_type)(
  44. void*, win_iocp_operation*,
  45. const asio::error_code&, std::size_t);
  46. win_iocp_operation(func_type func)
  47. : next_(0),
  48. func_(func)
  49. {
  50. reset();
  51. }
  52. // Prevents deletion through this type.
  53. ~win_iocp_operation()
  54. {
  55. }
  56. void reset()
  57. {
  58. Internal = 0;
  59. InternalHigh = 0;
  60. Offset = 0;
  61. OffsetHigh = 0;
  62. hEvent = 0;
  63. ready_ = 0;
  64. }
  65. private:
  66. friend class op_queue_access;
  67. friend class win_iocp_io_context;
  68. win_iocp_operation* next_;
  69. func_type func_;
  70. long ready_;
  71. };
  72. } // namespace detail
  73. } // namespace asio
  74. #include "asio/detail/pop_options.hpp"
  75. #endif // defined(ASIO_HAS_IOCP)
  76. #endif // ASIO_DETAIL_WIN_IOCP_OPERATION_HPP