Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:11

0001 //
0002 // system_context.hpp
0003 // ~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_SYSTEM_CONTEXT_HPP
0012 #define BOOST_ASIO_SYSTEM_CONTEXT_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/scheduler.hpp>
0020 #include <boost/asio/detail/thread_group.hpp>
0021 #include <boost/asio/execution.hpp>
0022 #include <boost/asio/execution_context.hpp>
0023 
0024 #include <boost/asio/detail/push_options.hpp>
0025 
0026 namespace boost {
0027 namespace asio {
0028 
0029 template <typename Blocking, typename Relationship, typename Allocator>
0030 class basic_system_executor;
0031 
0032 /// The executor context for the system executor.
0033 class system_context : public execution_context
0034 {
0035 public:
0036   /// The executor type associated with the context.
0037   typedef basic_system_executor<
0038       execution::blocking_t::possibly_t,
0039       execution::relationship_t::fork_t,
0040       std::allocator<void>
0041     > executor_type;
0042 
0043   /// Destructor shuts down all threads in the system thread pool.
0044   BOOST_ASIO_DECL ~system_context();
0045 
0046   /// Obtain an executor for the context.
0047   executor_type get_executor() noexcept;
0048 
0049   /// Signal all threads in the system thread pool to stop.
0050   BOOST_ASIO_DECL void stop();
0051 
0052   /// Determine whether the system thread pool has been stopped.
0053   BOOST_ASIO_DECL bool stopped() const noexcept;
0054 
0055   /// Join all threads in the system thread pool.
0056   BOOST_ASIO_DECL void join();
0057 
0058 #if defined(GENERATING_DOCUMENTATION)
0059 private:
0060 #endif // defined(GENERATING_DOCUMENTATION)
0061   // Constructor creates all threads in the system thread pool.
0062   BOOST_ASIO_DECL system_context();
0063 
0064 private:
0065   template <typename, typename, typename> friend class basic_system_executor;
0066 
0067   struct thread_function;
0068 
0069   // Helper function to create the underlying scheduler.
0070   BOOST_ASIO_DECL detail::scheduler& add_scheduler(detail::scheduler* s);
0071 
0072   // The underlying scheduler.
0073   detail::scheduler& scheduler_;
0074 
0075   // The threads in the system thread pool.
0076   detail::thread_group threads_;
0077 
0078   // The number of threads in the pool.
0079   std::size_t num_threads_;
0080 };
0081 
0082 } // namespace asio
0083 } // namespace boost
0084 
0085 #include <boost/asio/detail/pop_options.hpp>
0086 
0087 #include <boost/asio/impl/system_context.hpp>
0088 #if defined(BOOST_ASIO_HEADER_ONLY)
0089 # include <boost/asio/impl/system_context.ipp>
0090 #endif // defined(BOOST_ASIO_HEADER_ONLY)
0091 
0092 #endif // BOOST_ASIO_SYSTEM_CONTEXT_HPP