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.

79 lines
1.8KB

  1. //
  2. // detail/scheduler_operation.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_DETAIL_SCHEDULER_OPERATION_HPP
  11. #define ASIO_DETAIL_SCHEDULER_OPERATION_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/error_code.hpp"
  16. #include "asio/detail/handler_tracking.hpp"
  17. #include "asio/detail/op_queue.hpp"
  18. #include "asio/detail/push_options.hpp"
  19. namespace asio {
  20. namespace detail {
  21. class scheduler;
  22. // Base class for all operations. A function pointer is used instead of virtual
  23. // functions to avoid the associated overhead.
  24. class scheduler_operation ASIO_INHERIT_TRACKED_HANDLER
  25. {
  26. public:
  27. typedef scheduler_operation operation_type;
  28. void complete(void* owner, const asio::error_code& ec,
  29. std::size_t bytes_transferred)
  30. {
  31. func_(owner, this, ec, bytes_transferred);
  32. }
  33. void destroy()
  34. {
  35. func_(0, this, asio::error_code(), 0);
  36. }
  37. protected:
  38. typedef void (*func_type)(void*,
  39. scheduler_operation*,
  40. const asio::error_code&, std::size_t);
  41. scheduler_operation(func_type func)
  42. : next_(0),
  43. func_(func),
  44. task_result_(0)
  45. {
  46. }
  47. // Prevents deletion through this type.
  48. ~scheduler_operation()
  49. {
  50. }
  51. private:
  52. friend class op_queue_access;
  53. scheduler_operation* next_;
  54. func_type func_;
  55. protected:
  56. friend class scheduler;
  57. unsigned int task_result_; // Passed into bytes transferred.
  58. };
  59. } // namespace detail
  60. } // namespace asio
  61. #include "asio/detail/pop_options.hpp"
  62. #endif // ASIO_DETAIL_SCHEDULER_OPERATION_HPP