wait_result.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * Copyright (c) 2025 Andrey Semashev
  7. */
  8. /*!
  9. * \file atomic/wait_result.hpp
  10. *
  11. * This header contains definition of the \c wait_result class template.
  12. */
  13. #ifndef BOOST_ATOMIC_WAIT_RESULT_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_WAIT_RESULT_HPP_INCLUDED_
  15. #include <type_traits>
  16. #include <boost/atomic/detail/config.hpp>
  17. #include <boost/atomic/detail/header.hpp>
  18. #ifdef BOOST_HAS_PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. namespace boost {
  22. namespace atomics {
  23. //! The structure contains the result of a timed waiting operation
  24. template< typename T >
  25. struct wait_result
  26. {
  27. //! Last value read as part of the waiting operation
  28. T value;
  29. //! Indicates whether the waiting operation has ended due to timeout
  30. bool timeout;
  31. constexpr wait_result() noexcept(std::is_nothrow_default_constructible< T >::value) :
  32. value(),
  33. timeout(false)
  34. {
  35. }
  36. template< typename U, typename = typename std::enable_if< std::is_constructible< T, U&& >::value >::type >
  37. constexpr wait_result(U&& val, bool tout) noexcept(std::is_nothrow_constructible< T, U&& >::value) :
  38. value(static_cast< U&& >(val)),
  39. timeout(tout)
  40. {
  41. }
  42. };
  43. } // namespace atomics
  44. } // namespace boost
  45. #include <boost/atomic/detail/footer.hpp>
  46. #endif // BOOST_ATOMIC_WAIT_RESULT_HPP_INCLUDED_