Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:41

0001 //
0002 // detail/is_executor.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_DETAIL_IS_EXECUTOR_HPP
0012 #define BOOST_ASIO_DETAIL_IS_EXECUTOR_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/type_traits.hpp>
0020 
0021 #include <boost/asio/detail/push_options.hpp>
0022 
0023 namespace boost {
0024 namespace asio {
0025 namespace detail {
0026 
0027 struct executor_memfns_base
0028 {
0029   void context();
0030   void on_work_started();
0031   void on_work_finished();
0032   void dispatch();
0033   void post();
0034   void defer();
0035 };
0036 
0037 template <typename T>
0038 struct executor_memfns_derived
0039   : T, executor_memfns_base
0040 {
0041 };
0042 
0043 template <typename T, T>
0044 struct executor_memfns_check
0045 {
0046 };
0047 
0048 template <typename>
0049 char (&context_memfn_helper(...))[2];
0050 
0051 template <typename T>
0052 char context_memfn_helper(
0053     executor_memfns_check<
0054       void (executor_memfns_base::*)(),
0055       &executor_memfns_derived<T>::context>*);
0056 
0057 template <typename>
0058 char (&on_work_started_memfn_helper(...))[2];
0059 
0060 template <typename T>
0061 char on_work_started_memfn_helper(
0062     executor_memfns_check<
0063       void (executor_memfns_base::*)(),
0064       &executor_memfns_derived<T>::on_work_started>*);
0065 
0066 template <typename>
0067 char (&on_work_finished_memfn_helper(...))[2];
0068 
0069 template <typename T>
0070 char on_work_finished_memfn_helper(
0071     executor_memfns_check<
0072       void (executor_memfns_base::*)(),
0073       &executor_memfns_derived<T>::on_work_finished>*);
0074 
0075 template <typename>
0076 char (&dispatch_memfn_helper(...))[2];
0077 
0078 template <typename T>
0079 char dispatch_memfn_helper(
0080     executor_memfns_check<
0081       void (executor_memfns_base::*)(),
0082       &executor_memfns_derived<T>::dispatch>*);
0083 
0084 template <typename>
0085 char (&post_memfn_helper(...))[2];
0086 
0087 template <typename T>
0088 char post_memfn_helper(
0089     executor_memfns_check<
0090       void (executor_memfns_base::*)(),
0091       &executor_memfns_derived<T>::post>*);
0092 
0093 template <typename>
0094 char (&defer_memfn_helper(...))[2];
0095 
0096 template <typename T>
0097 char defer_memfn_helper(
0098     executor_memfns_check<
0099       void (executor_memfns_base::*)(),
0100       &executor_memfns_derived<T>::defer>*);
0101 
0102 template <typename T>
0103 struct is_executor_class
0104   : integral_constant<bool,
0105       sizeof(context_memfn_helper<T>(0)) != 1 &&
0106       sizeof(on_work_started_memfn_helper<T>(0)) != 1 &&
0107       sizeof(on_work_finished_memfn_helper<T>(0)) != 1 &&
0108       sizeof(dispatch_memfn_helper<T>(0)) != 1 &&
0109       sizeof(post_memfn_helper<T>(0)) != 1 &&
0110       sizeof(defer_memfn_helper<T>(0)) != 1>
0111 {
0112 };
0113 
0114 template <typename T>
0115 struct is_executor
0116   : conditional<is_class<T>::value,
0117       is_executor_class<T>,
0118       false_type>::type
0119 {
0120 };
0121 
0122 } // namespace detail
0123 } // namespace asio
0124 } // namespace boost
0125 
0126 #include <boost/asio/detail/pop_options.hpp>
0127 
0128 #endif // BOOST_ASIO_DETAIL_IS_EXECUTOR_HPP