File indexing completed on 2025-01-18 09:28:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_HANDLER_TRACKING_HPP
0012 #define BOOST_ASIO_DETAIL_HANDLER_TRACKING_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 namespace boost {
0021 namespace asio {
0022
0023 class execution_context;
0024
0025 }
0026 }
0027
0028 #if defined(BOOST_ASIO_CUSTOM_HANDLER_TRACKING)
0029 # include BOOST_ASIO_CUSTOM_HANDLER_TRACKING
0030 #elif defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
0031 # include <boost/system/error_code.hpp>
0032 # include <boost/asio/detail/cstdint.hpp>
0033 # include <boost/asio/detail/static_mutex.hpp>
0034 # include <boost/asio/detail/tss_ptr.hpp>
0035 #endif
0036
0037 #include <boost/asio/detail/push_options.hpp>
0038
0039 namespace boost {
0040 namespace asio {
0041 namespace detail {
0042
0043 #if defined(BOOST_ASIO_CUSTOM_HANDLER_TRACKING)
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 # if !defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
0063 # define BOOST_ASIO_ENABLE_HANDLER_TRACKING 1
0064 # endif
0065
0066 #elif defined(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
0067
0068 class handler_tracking
0069 {
0070 public:
0071 class completion;
0072
0073
0074 class tracked_handler
0075 {
0076 private:
0077
0078 friend class handler_tracking;
0079 friend class completion;
0080 uint64_t id_;
0081
0082 protected:
0083
0084 tracked_handler() : id_(0) {}
0085
0086
0087 ~tracked_handler() {}
0088 };
0089
0090
0091 BOOST_ASIO_DECL static void init();
0092
0093 class location
0094 {
0095 public:
0096
0097 BOOST_ASIO_DECL explicit location(const char* file,
0098 int line, const char* func);
0099
0100
0101 BOOST_ASIO_DECL ~location();
0102
0103 private:
0104
0105 location(const location&) = delete;
0106 location& operator=(const location&) = delete;
0107
0108 friend class handler_tracking;
0109 const char* file_;
0110 int line_;
0111 const char* func_;
0112 location* next_;
0113 };
0114
0115
0116 BOOST_ASIO_DECL static void creation(
0117 execution_context& context, tracked_handler& h,
0118 const char* object_type, void* object,
0119 uintmax_t native_handle, const char* op_name);
0120
0121 class completion
0122 {
0123 public:
0124
0125 BOOST_ASIO_DECL explicit completion(const tracked_handler& h);
0126
0127
0128
0129 BOOST_ASIO_DECL ~completion();
0130
0131
0132 BOOST_ASIO_DECL void invocation_begin();
0133
0134
0135 BOOST_ASIO_DECL void invocation_begin(const boost::system::error_code& ec);
0136
0137
0138 BOOST_ASIO_DECL void invocation_begin(
0139 const boost::system::error_code& ec, std::size_t bytes_transferred);
0140
0141
0142 BOOST_ASIO_DECL void invocation_begin(
0143 const boost::system::error_code& ec, int signal_number);
0144
0145
0146 BOOST_ASIO_DECL void invocation_begin(
0147 const boost::system::error_code& ec, const char* arg);
0148
0149
0150 BOOST_ASIO_DECL void invocation_end();
0151
0152 private:
0153 friend class handler_tracking;
0154 uint64_t id_;
0155 bool invoked_;
0156 completion* next_;
0157 };
0158
0159
0160 BOOST_ASIO_DECL static void operation(execution_context& context,
0161 const char* object_type, void* object,
0162 uintmax_t native_handle, const char* op_name);
0163
0164
0165 BOOST_ASIO_DECL static void reactor_registration(execution_context& context,
0166 uintmax_t native_handle, uintmax_t registration);
0167
0168
0169 BOOST_ASIO_DECL static void reactor_deregistration(execution_context& context,
0170 uintmax_t native_handle, uintmax_t registration);
0171
0172
0173 BOOST_ASIO_DECL static void reactor_events(execution_context& context,
0174 uintmax_t registration, unsigned events);
0175
0176
0177 BOOST_ASIO_DECL static void reactor_operation(
0178 const tracked_handler& h, const char* op_name,
0179 const boost::system::error_code& ec);
0180
0181
0182 BOOST_ASIO_DECL static void reactor_operation(
0183 const tracked_handler& h, const char* op_name,
0184 const boost::system::error_code& ec, std::size_t bytes_transferred);
0185
0186
0187 BOOST_ASIO_DECL static void write_line(const char* format, ...);
0188
0189 private:
0190 struct tracking_state;
0191 BOOST_ASIO_DECL static tracking_state* get_state();
0192 };
0193
0194 # define BOOST_ASIO_INHERIT_TRACKED_HANDLER \
0195 : public boost::asio::detail::handler_tracking::tracked_handler
0196
0197 # define BOOST_ASIO_ALSO_INHERIT_TRACKED_HANDLER \
0198 , public boost::asio::detail::handler_tracking::tracked_handler
0199
0200 # define BOOST_ASIO_HANDLER_TRACKING_INIT \
0201 boost::asio::detail::handler_tracking::init()
0202
0203 # define BOOST_ASIO_HANDLER_LOCATION(args) \
0204 boost::asio::detail::handler_tracking::location tracked_location args
0205
0206 # define BOOST_ASIO_HANDLER_CREATION(args) \
0207 boost::asio::detail::handler_tracking::creation args
0208
0209 # define BOOST_ASIO_HANDLER_COMPLETION(args) \
0210 boost::asio::detail::handler_tracking::completion tracked_completion args
0211
0212 # define BOOST_ASIO_HANDLER_INVOCATION_BEGIN(args) \
0213 tracked_completion.invocation_begin args
0214
0215 # define BOOST_ASIO_HANDLER_INVOCATION_END \
0216 tracked_completion.invocation_end()
0217
0218 # define BOOST_ASIO_HANDLER_OPERATION(args) \
0219 boost::asio::detail::handler_tracking::operation args
0220
0221 # define BOOST_ASIO_HANDLER_REACTOR_REGISTRATION(args) \
0222 boost::asio::detail::handler_tracking::reactor_registration args
0223
0224 # define BOOST_ASIO_HANDLER_REACTOR_DEREGISTRATION(args) \
0225 boost::asio::detail::handler_tracking::reactor_deregistration args
0226
0227 # define BOOST_ASIO_HANDLER_REACTOR_READ_EVENT 1
0228 # define BOOST_ASIO_HANDLER_REACTOR_WRITE_EVENT 2
0229 # define BOOST_ASIO_HANDLER_REACTOR_ERROR_EVENT 4
0230
0231 # define BOOST_ASIO_HANDLER_REACTOR_EVENTS(args) \
0232 boost::asio::detail::handler_tracking::reactor_events args
0233
0234 # define BOOST_ASIO_HANDLER_REACTOR_OPERATION(args) \
0235 boost::asio::detail::handler_tracking::reactor_operation args
0236
0237 #else
0238
0239 # define BOOST_ASIO_INHERIT_TRACKED_HANDLER
0240 # define BOOST_ASIO_ALSO_INHERIT_TRACKED_HANDLER
0241 # define BOOST_ASIO_HANDLER_TRACKING_INIT (void)0
0242 # define BOOST_ASIO_HANDLER_LOCATION(loc) (void)0
0243 # define BOOST_ASIO_HANDLER_CREATION(args) (void)0
0244 # define BOOST_ASIO_HANDLER_COMPLETION(args) (void)0
0245 # define BOOST_ASIO_HANDLER_INVOCATION_BEGIN(args) (void)0
0246 # define BOOST_ASIO_HANDLER_INVOCATION_END (void)0
0247 # define BOOST_ASIO_HANDLER_OPERATION(args) (void)0
0248 # define BOOST_ASIO_HANDLER_REACTOR_REGISTRATION(args) (void)0
0249 # define BOOST_ASIO_HANDLER_REACTOR_DEREGISTRATION(args) (void)0
0250 # define BOOST_ASIO_HANDLER_REACTOR_READ_EVENT 0
0251 # define BOOST_ASIO_HANDLER_REACTOR_WRITE_EVENT 0
0252 # define BOOST_ASIO_HANDLER_REACTOR_ERROR_EVENT 0
0253 # define BOOST_ASIO_HANDLER_REACTOR_EVENTS(args) (void)0
0254 # define BOOST_ASIO_HANDLER_REACTOR_OPERATION(args) (void)0
0255
0256 #endif
0257
0258 }
0259 }
0260 }
0261
0262 #include <boost/asio/detail/pop_options.hpp>
0263
0264 #if defined(BOOST_ASIO_HEADER_ONLY)
0265 # include <boost/asio/detail/impl/handler_tracking.ipp>
0266 #endif
0267
0268 #endif