1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
//
// detail/is_executor.hpp
// ~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_DETAIL_IS_EXECUTOR_HPP
#define ASIO_DETAIL_IS_EXECUTOR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include "asio/detail/type_traits.hpp"
#include "asio/detail/push_options.hpp"
namespace asio {
namespace detail {
struct executor_memfns_base
{
void context();
void on_work_started();
void on_work_finished();
void dispatch();
void post();
void defer();
};
template <typename T>
struct executor_memfns_derived
: T, executor_memfns_base
{
};
template <typename T, T>
struct executor_memfns_check
{
};
template <typename>
char (&context_memfn_helper(...))[2];
template <typename T>
char context_memfn_helper(
executor_memfns_check<
void (executor_memfns_base::*)(),
&executor_memfns_derived<T>::context>*);
template <typename>
char (&on_work_started_memfn_helper(...))[2];
template <typename T>
char on_work_started_memfn_helper(
executor_memfns_check<
void (executor_memfns_base::*)(),
&executor_memfns_derived<T>::on_work_started>*);
template <typename>
char (&on_work_finished_memfn_helper(...))[2];
template <typename T>
char on_work_finished_memfn_helper(
executor_memfns_check<
void (executor_memfns_base::*)(),
&executor_memfns_derived<T>::on_work_finished>*);
template <typename>
char (&dispatch_memfn_helper(...))[2];
template <typename T>
char dispatch_memfn_helper(
executor_memfns_check<
void (executor_memfns_base::*)(),
&executor_memfns_derived<T>::dispatch>*);
template <typename>
char (&post_memfn_helper(...))[2];
template <typename T>
char post_memfn_helper(
executor_memfns_check<
void (executor_memfns_base::*)(),
&executor_memfns_derived<T>::post>*);
template <typename>
char (&defer_memfn_helper(...))[2];
template <typename T>
char defer_memfn_helper(
executor_memfns_check<
void (executor_memfns_base::*)(),
&executor_memfns_derived<T>::defer>*);
template <typename T>
struct is_executor_class
: integral_constant<bool,
sizeof(context_memfn_helper<T>(0)) != 1 &&
sizeof(on_work_started_memfn_helper<T>(0)) != 1 &&
sizeof(on_work_finished_memfn_helper<T>(0)) != 1 &&
sizeof(dispatch_memfn_helper<T>(0)) != 1 &&
sizeof(post_memfn_helper<T>(0)) != 1 &&
sizeof(defer_memfn_helper<T>(0)) != 1>
{
};
template <typename T>
struct is_executor
: conditional<is_class<T>::value,
is_executor_class<T>,
false_type>::type
{
};
} // namespace detail
} // namespace asio
#include "asio/detail/pop_options.hpp"
#endif // ASIO_DETAIL_IS_EXECUTOR_HPP
|