]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/detail/impl/null_event.ipp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / asio / detail / impl / null_event.ipp
CommitLineData
b32b8144
FG
1//
2// detail/impl/null_event.ipp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~~
4//
92f5a8d4 5// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
b32b8144
FG
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
11#ifndef BOOST_ASIO_DETAIL_IMPL_NULL_EVENT_IPP
12#define BOOST_ASIO_DETAIL_IMPL_NULL_EVENT_IPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/config.hpp>
19
20#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
21# include <thread>
22#elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
23# include <boost/asio/detail/socket_types.hpp>
24#else
25# include <unistd.h>
26# if defined(__hpux)
27# include <sys/time.h>
28# endif
29# if !defined(__hpux) || defined(__SELECT)
30# include <sys/select.h>
31# endif
32#endif
33
34#include <boost/asio/detail/push_options.hpp>
35
36namespace boost {
37namespace asio {
38namespace detail {
39
40void null_event::do_wait()
41{
42#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
43 std::this_thread::sleep_until((std::chrono::steady_clock::time_point::max)());
44#elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
45 ::Sleep(INFINITE);
46#else
47 ::pause();
48#endif
49}
50
51void null_event::do_wait_for_usec(long usec)
52{
53#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
54 std::this_thread::sleep_for(std::chrono::microseconds(usec));
55#elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
56 ::Sleep(usec / 1000);
57#elif defined(__hpux) && defined(__SELECT)
58 timespec ts;
59 ts.tv_sec = usec / 1000000;
60 ts.tv_nsec = (usec % 1000000) * 1000;
61 ::pselect(0, 0, 0, 0, &ts, 0);
62#else
63 timeval tv;
64 tv.tv_sec = usec / 1000000;
65 tv.tv_usec = usec % 1000000;
66 ::select(0, 0, 0, 0, &tv);
67#endif
68}
69
70} // namespace detail
71} // namespace asio
72} // namespace boost
73
74#include <boost/asio/detail/pop_options.hpp>
75
76#endif // BOOST_ASIO_DETAIL_IMPL_NULL_EVENT_IPP