posix_clock_traits_fwd.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/posix_clock_traits_fwd.hpp
  10. *
  11. * This header contains declaration of the \c posix_clock_traits class template.
  12. */
  13. #ifndef BOOST_ATOMIC_POSIX_CLOCK_TRAITS_FWD_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_POSIX_CLOCK_TRAITS_FWD_HPP_INCLUDED_
  15. #include <boost/atomic/detail/config.hpp>
  16. #include <boost/atomic/detail/header.hpp>
  17. #ifdef BOOST_HAS_PRAGMA_ONCE
  18. #pragma once
  19. #endif
  20. namespace boost {
  21. namespace atomics {
  22. /*!
  23. * \brief The structure contains traits for compatibility between chrono clocks and POSIX clocks.
  24. *
  25. * This class template is meant to be specialized for clock types that are compatible with `std::chrono`
  26. * requirements and are based on one of the POSIX clocks identified by
  27. * a [`clockid_t`](https://man7.org/linux/man-pages/man3/clockid_t.3type.html) constant.
  28. *
  29. * Every specialization of this class must support the following interface:
  30. *
  31. * ```
  32. * // POSIX clock identifier
  33. * static constexpr clockid_t clock_id = ...;
  34. *
  35. * // Function that converts a time point to a timespec structure
  36. * static timespec to_timespec(Clock::time_point time_point) noexcept;
  37. * ```
  38. *
  39. * Note that the `timespec` structure returned from `to_timespec` must use the identified POSIX
  40. * clock epoch and time units. There are no invalid input `time_point` values, so `to_timespec`
  41. * must never fail with an exception.
  42. *
  43. * The second template parameter of this class template may be used by partial specializations
  44. * to leverage SFINAE to selectively enable it for a set of clock types.
  45. */
  46. template< typename Clock, typename = void >
  47. struct posix_clock_traits;
  48. } // namespace atomics
  49. } // namespace boost
  50. #include <boost/atomic/detail/footer.hpp>
  51. #endif // BOOST_ATOMIC_POSIX_CLOCK_TRAITS_FWD_HPP_INCLUDED_