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.

system_executor.hpp 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //
  2. // system_executor.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_SYSTEM_EXECUTOR_HPP
  11. #define ASIO_SYSTEM_EXECUTOR_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 "asio/detail/push_options.hpp"
  17. namespace asio {
  18. class system_context;
  19. /// An executor that uses arbitrary threads.
  20. /**
  21. * The system executor represents an execution context where functions are
  22. * permitted to run on arbitrary threads. The post() and defer() functions
  23. * schedule the function to run on an unspecified system thread pool, and
  24. * dispatch() invokes the function immediately.
  25. */
  26. class system_executor
  27. {
  28. public:
  29. /// Obtain the underlying execution context.
  30. system_context& context() const ASIO_NOEXCEPT;
  31. /// Inform the executor that it has some outstanding work to do.
  32. /**
  33. * For the system executor, this is a no-op.
  34. */
  35. void on_work_started() const ASIO_NOEXCEPT
  36. {
  37. }
  38. /// Inform the executor that some work is no longer outstanding.
  39. /**
  40. * For the system executor, this is a no-op.
  41. */
  42. void on_work_finished() const ASIO_NOEXCEPT
  43. {
  44. }
  45. /// Request the system executor to invoke the given function object.
  46. /**
  47. * This function is used to ask the executor to execute the given function
  48. * object. The function object will always be executed inside this function.
  49. *
  50. * @param f The function object to be called. The executor will make
  51. * a copy of the handler object as required. The function signature of the
  52. * function object must be: @code void function(); @endcode
  53. *
  54. * @param a An allocator that may be used by the executor to allocate the
  55. * internal storage needed for function invocation.
  56. */
  57. template <typename Function, typename Allocator>
  58. void dispatch(ASIO_MOVE_ARG(Function) f, const Allocator& a) const;
  59. /// Request the system executor to invoke the given function object.
  60. /**
  61. * This function is used to ask the executor to execute the given function
  62. * object. The function object will never be executed inside this function.
  63. * Instead, it will be scheduled to run on an unspecified system thread pool.
  64. *
  65. * @param f The function object to be called. The executor will make
  66. * a copy of the handler object as required. The function signature of the
  67. * function object must be: @code void function(); @endcode
  68. *
  69. * @param a An allocator that may be used by the executor to allocate the
  70. * internal storage needed for function invocation.
  71. */
  72. template <typename Function, typename Allocator>
  73. void post(ASIO_MOVE_ARG(Function) f, const Allocator& a) const;
  74. /// Request the system executor to invoke the given function object.
  75. /**
  76. * This function is used to ask the executor to execute the given function
  77. * object. The function object will never be executed inside this function.
  78. * Instead, it will be scheduled to run on an unspecified system thread pool.
  79. *
  80. * @param f The function object to be called. The executor will make
  81. * a copy of the handler object as required. The function signature of the
  82. * function object must be: @code void function(); @endcode
  83. *
  84. * @param a An allocator that may be used by the executor to allocate the
  85. * internal storage needed for function invocation.
  86. */
  87. template <typename Function, typename Allocator>
  88. void defer(ASIO_MOVE_ARG(Function) f, const Allocator& a) const;
  89. /// Compare two executors for equality.
  90. /**
  91. * System executors always compare equal.
  92. */
  93. friend bool operator==(const system_executor&,
  94. const system_executor&) ASIO_NOEXCEPT
  95. {
  96. return true;
  97. }
  98. /// Compare two executors for inequality.
  99. /**
  100. * System executors always compare equal.
  101. */
  102. friend bool operator!=(const system_executor&,
  103. const system_executor&) ASIO_NOEXCEPT
  104. {
  105. return false;
  106. }
  107. };
  108. } // namespace asio
  109. #include "asio/detail/pop_options.hpp"
  110. #include "asio/impl/system_executor.hpp"
  111. #endif // ASIO_SYSTEM_EXECUTOR_HPP