thread_context.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // detail/thread_context.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2023 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 ASIO_DETAIL_THREAD_CONTEXT_HPP
  11. #define ASIO_DETAIL_THREAD_CONTEXT_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <climits>
  16. #include <cstddef>
  17. #include "asio/detail/call_stack.hpp"
  18. #include "asio/detail/push_options.hpp"
  19. namespace asio {
  20. namespace detail {
  21. class thread_info_base;
  22. // Base class for things that manage threads (scheduler, win_iocp_io_context).
  23. class thread_context
  24. {
  25. public:
  26. // Obtain a pointer to the top of the thread call stack. Returns null when
  27. // not running inside a thread context.
  28. ASIO_DECL static thread_info_base* top_of_thread_call_stack();
  29. protected:
  30. // Per-thread call stack to track the state of each thread in the context.
  31. typedef call_stack<thread_context, thread_info_base> thread_call_stack;
  32. };
  33. } // namespace detail
  34. } // namespace asio
  35. #include "asio/detail/pop_options.hpp"
  36. #if defined(ASIO_HEADER_ONLY)
  37. # include "asio/detail/impl/thread_context.ipp"
  38. #endif // defined(ASIO_HEADER_ONLY)
  39. #endif // ASIO_DETAIL_THREAD_CONTEXT_HPP