detached.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // experimental/detached.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 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 BOOST_ASIO_EXPERIMENTAL_DETACHED_HPP
  11. #define BOOST_ASIO_EXPERIMENTAL_DETACHED_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <memory>
  17. #include <boost/asio/detail/push_options.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace experimental {
  21. /// Class used to specify that an asynchronous operation is detached.
  22. /**
  23. * The detached_t class is used to indicate that an asynchronous operation is
  24. * detached. That is, there is no completion handler waiting for the
  25. * operation's result. A detached_t object may be passed as a handler to an
  26. * asynchronous operation, typically using the special value
  27. * @c boost::asio::experimental::detached. For example:
  28. * @code my_socket.async_send(my_buffer, boost::asio::experimental::detached);
  29. * @endcode
  30. */
  31. class detached_t
  32. {
  33. public:
  34. /// Constructor.
  35. BOOST_ASIO_CONSTEXPR detached_t()
  36. {
  37. }
  38. };
  39. /// A special value, similar to std::nothrow.
  40. /**
  41. * See the documentation for boost::asio::experimental::detached_t for a usage
  42. * example.
  43. */
  44. #if defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
  45. constexpr detached_t detached;
  46. #elif defined(BOOST_ASIO_MSVC)
  47. __declspec(selectany) detached_t detached;
  48. #endif
  49. } // namespace experimental
  50. } // namespace asio
  51. } // namespace boost
  52. #include <boost/asio/detail/pop_options.hpp>
  53. #include <boost/asio/experimental/impl/detached.hpp>
  54. #endif // BOOST_ASIO_EXPERIMENTAL_DETACHED_HPP