]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/detail/concurrency_hint.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / asio / detail / concurrency_hint.hpp
1 //
2 // detail/concurrency_hint.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2017 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
11 #ifndef BOOST_ASIO_DETAIL_CONCURRENCY_HINT_HPP
12 #define BOOST_ASIO_DETAIL_CONCURRENCY_HINT_HPP
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 #include <boost/asio/detail/noncopyable.hpp>
20
21 // The concurrency hint ID and mask are used to identify when a "well-known"
22 // concurrency hint value has been passed to the io_context.
23 #define BOOST_ASIO_CONCURRENCY_HINT_ID 0xA5100000u
24 #define BOOST_ASIO_CONCURRENCY_HINT_ID_MASK 0xFFFF0000u
25
26 // If set, this bit indicates that the scheduler should perform locking.
27 #define BOOST_ASIO_CONCURRENCY_HINT_LOCKING_SCHEDULER 0x1u
28
29 // If set, this bit indicates that the reactor should perform locking when
30 // managing descriptor registrations.
31 #define BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_REGISTRATION 0x2u
32
33 // If set, this bit indicates that the reactor should perform locking for I/O.
34 #define BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_IO 0x4u
35
36 // Helper macro to determine if we have a special concurrency hint.
37 #define BOOST_ASIO_CONCURRENCY_HINT_IS_SPECIAL(hint) \
38 ((static_cast<unsigned>(hint) \
39 & BOOST_ASIO_CONCURRENCY_HINT_ID_MASK) \
40 == BOOST_ASIO_CONCURRENCY_HINT_ID)
41
42 // Helper macro to determine if locking is enabled for a given facility.
43 #define BOOST_ASIO_CONCURRENCY_HINT_IS_LOCKING(facility, hint) \
44 (((static_cast<unsigned>(hint) \
45 & (BOOST_ASIO_CONCURRENCY_HINT_ID_MASK \
46 | BOOST_ASIO_CONCURRENCY_HINT_LOCKING_ ## facility)) \
47 ^ BOOST_ASIO_CONCURRENCY_HINT_ID) != 0)
48
49 // This special concurrency hint disables locking in both the scheduler and
50 // reactor I/O. This hint has the following restrictions:
51 //
52 // - Care must be taken to ensure that all operations on the io_context and any
53 // of its associated I/O objects (such as sockets and timers) occur in only
54 // one thread at a time.
55 //
56 // - Asynchronous resolve operations fail with operation_not_supported.
57 //
58 // - If a signal_set is used with the io_context, signal_set objects cannot be
59 // used with any other io_context in the program.
60 #define BOOST_ASIO_CONCURRENCY_HINT_UNSAFE \
61 static_cast<int>(BOOST_ASIO_CONCURRENCY_HINT_ID)
62
63 // This special concurrency hint disables locking in the reactor I/O. This hint
64 // has the following restrictions:
65 //
66 // - Care must be taken to ensure that run functions on the io_context, and all
67 // operations on the io_context's associated I/O objects (such as sockets and
68 // timers), occur in only one thread at a time.
69 #define BOOST_ASIO_CONCURRENCY_HINT_UNSAFE_IO \
70 static_cast<int>(BOOST_ASIO_CONCURRENCY_HINT_ID \
71 | BOOST_ASIO_CONCURRENCY_HINT_LOCKING_SCHEDULER \
72 | BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_REGISTRATION)
73
74 // The special concurrency hint provides full thread safety.
75 #define BOOST_ASIO_CONCURRENCY_HINT_SAFE \
76 static_cast<int>(BOOST_ASIO_CONCURRENCY_HINT_ID \
77 | BOOST_ASIO_CONCURRENCY_HINT_LOCKING_SCHEDULER \
78 | BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_REGISTRATION \
79 | BOOST_ASIO_CONCURRENCY_HINT_LOCKING_REACTOR_IO)
80
81 // This #define may be overridden at compile time to specify a program-wide
82 // default concurrency hint, used by the zero-argument io_context constructor.
83 #if !defined(BOOST_ASIO_CONCURRENCY_HINT_DEFAULT)
84 # define BOOST_ASIO_CONCURRENCY_HINT_DEFAULT -1
85 #endif // !defined(BOOST_ASIO_CONCURRENCY_HINT_DEFAULT)
86
87 // This #define may be overridden at compile time to specify a program-wide
88 // concurrency hint, used by the one-argument io_context constructor when
89 // passed a value of 1.
90 #if !defined(BOOST_ASIO_CONCURRENCY_HINT_1)
91 # define BOOST_ASIO_CONCURRENCY_HINT_1 1
92 #endif // !defined(BOOST_ASIO_CONCURRENCY_HINT_DEFAULT)
93
94 #endif // BOOST_ASIO_DETAIL_CONCURRENCY_HINT_HPP