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.ipp 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // impl/system_executor.ipp
  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_IMPL_SYSTEM_EXECUTOR_IPP
  11. #define ASIO_IMPL_SYSTEM_EXECUTOR_IPP
  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/system_executor.hpp"
  17. #include "asio/detail/push_options.hpp"
  18. namespace asio {
  19. struct system_executor::thread_function
  20. {
  21. detail::scheduler* scheduler_;
  22. void operator()()
  23. {
  24. asio::error_code ec;
  25. scheduler_->run(ec);
  26. }
  27. };
  28. system_executor::context_impl::context_impl()
  29. : scheduler_(use_service<detail::scheduler>(*this))
  30. {
  31. scheduler_.work_started();
  32. thread_function f = { &scheduler_ };
  33. std::size_t num_threads = detail::thread::hardware_concurrency() * 2;
  34. threads_.create_threads(f, num_threads ? num_threads : 2);
  35. }
  36. system_executor::context_impl::~context_impl()
  37. {
  38. scheduler_.work_finished();
  39. scheduler_.stop();
  40. threads_.join();
  41. }
  42. } // namespace asio
  43. #include "asio/detail/pop_options.hpp"
  44. #endif // ASIO_IMPL_SYSTEM_EXECUTOR_IPP