thread_id.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file thread_id.hpp
  9. * \author Andrey Semashev
  10. * \date 08.01.2012
  11. *
  12. * \brief This header is the Boost.Log library implementation, see the library documentation
  13. * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
  14. */
  15. #ifndef BOOST_LOG_DETAIL_THREAD_ID_HPP_INCLUDED_
  16. #define BOOST_LOG_DETAIL_THREAD_ID_HPP_INCLUDED_
  17. #include <iosfwd>
  18. #include <boost/cstdint.hpp>
  19. #include <boost/log/detail/config.hpp>
  20. #include <boost/log/detail/id.hpp>
  21. #include <boost/log/detail/header.hpp>
  22. #ifdef BOOST_HAS_PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. namespace boost {
  26. BOOST_LOG_OPEN_NAMESPACE
  27. namespace aux {
  28. //! The thread id descriptor
  29. struct thread
  30. {
  31. #if defined(BOOST_WINDOWS)
  32. typedef uint32_t native_type;
  33. #else
  34. typedef uintmax_t native_type;
  35. #endif
  36. typedef boost::log::aux::id< thread > id;
  37. };
  38. namespace this_thread {
  39. //! The function returns current thread identifier
  40. BOOST_LOG_API thread::id const& get_id();
  41. } // namespace this_thread
  42. template< typename CharT, typename TraitsT >
  43. BOOST_LOG_API std::basic_ostream< CharT, TraitsT >&
  44. operator<< (std::basic_ostream< CharT, TraitsT >& strm, thread::id const& tid);
  45. } // namespace aux
  46. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  47. } // namespace boost
  48. #include <boost/log/detail/footer.hpp>
  49. #endif // BOOST_LOG_DETAIL_THREAD_ID_HPP_INCLUDED_