File indexing completed on 2025-01-18 09:29:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_CORE_IMPL_SAVED_HANDLER_IPP
0011 #define BOOST_BEAST_CORE_IMPL_SAVED_HANDLER_IPP
0012
0013 #include <boost/beast/core/saved_handler.hpp>
0014 #include <boost/core/exchange.hpp>
0015
0016 namespace boost {
0017 namespace beast {
0018
0019 saved_handler::
0020 ~saved_handler()
0021 {
0022 if(p_)
0023 p_->destroy();
0024 }
0025
0026 saved_handler::
0027 saved_handler(saved_handler&& other) noexcept
0028 : p_(boost::exchange(other.p_, nullptr))
0029 {
0030 p_->set_owner(this);
0031 }
0032
0033 saved_handler&
0034 saved_handler::
0035 operator=(saved_handler&& other) noexcept
0036 {
0037
0038 BOOST_ASSERT(! has_value());
0039 p_ = boost::exchange(other.p_, nullptr);
0040 p_->set_owner(this);
0041 return *this;
0042 }
0043
0044 bool
0045 saved_handler::
0046 reset() noexcept
0047 {
0048 if(! p_)
0049 return false;
0050 boost::exchange(p_, nullptr)->destroy();
0051 return true;
0052 }
0053
0054 void
0055 saved_handler::
0056 invoke()
0057 {
0058
0059 BOOST_ASSERT(has_value());
0060 boost::exchange(
0061 p_, nullptr)->invoke();
0062 }
0063
0064 bool
0065 saved_handler::
0066 maybe_invoke()
0067 {
0068 if(! p_)
0069 return false;
0070 boost::exchange(
0071 p_, nullptr)->invoke();
0072 return true;
0073 }
0074
0075 }
0076 }
0077
0078 #endif