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.

null_event.ipp 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // detail/impl/null_event.ipp
  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_IMPL_NULL_EVENT_IPP
  11. #define ASIO_DETAIL_IMPL_NULL_EVENT_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. #if defined(ASIO_WINDOWS_RUNTIME)
  17. # include <thread>
  18. #elif defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  19. # include "asio/detail/socket_types.hpp"
  20. #else
  21. # include <unistd.h>
  22. # if defined(__hpux)
  23. # include <sys/time.h>
  24. # endif
  25. # if !defined(__hpux) || defined(__SELECT)
  26. # include <sys/select.h>
  27. # endif
  28. #endif
  29. #include "asio/detail/push_options.hpp"
  30. namespace asio {
  31. namespace detail {
  32. void null_event::do_wait()
  33. {
  34. #if defined(ASIO_WINDOWS_RUNTIME)
  35. std::this_thread::sleep_until((std::chrono::steady_clock::time_point::max)());
  36. #elif defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  37. ::Sleep(INFINITE);
  38. #else
  39. ::pause();
  40. #endif
  41. }
  42. void null_event::do_wait_for_usec(long usec)
  43. {
  44. #if defined(ASIO_WINDOWS_RUNTIME)
  45. std::this_thread::sleep_for(std::chrono::microseconds(usec));
  46. #elif defined(ASIO_WINDOWS) || defined(__CYGWIN__)
  47. ::Sleep(usec / 1000);
  48. #elif defined(__hpux) && defined(__SELECT)
  49. timespec ts;
  50. ts.tv_sec = usec / 1000000;
  51. ts.tv_nsec = (usec % 1000000) * 1000;
  52. ::pselect(0, 0, 0, 0, &ts, 0);
  53. #else
  54. timeval tv;
  55. tv.tv_sec = usec / 1000000;
  56. tv.tv_usec = usec % 1000000;
  57. ::select(0, 0, 0, 0, &tv);
  58. #endif
  59. }
  60. } // namespace detail
  61. } // namespace asio
  62. #include "asio/detail/pop_options.hpp"
  63. #endif // ASIO_DETAIL_IMPL_NULL_EVENT_IPP