17
17
18
18
#include " asio/detail/config.hpp"
19
19
#include " asio/coroutine.hpp"
20
- #include " asio/detail/shared_ptr.hpp"
21
20
#include " asio/detail/wrapped_handler.hpp"
22
21
#include " asio/io_service.hpp"
23
22
#include " asio/strand.hpp"
24
23
25
24
#include " asio/detail/push_options.hpp"
26
25
27
26
namespace asio {
27
+ namespace detail {
28
+
29
+ template <typename Handler> class stackless_impl_base ;
28
30
29
- namespace detail { template < typename Handler> class stackless_impl_base ; }
31
+ } // namespace detail
30
32
31
33
// / Context object the represents the currently executing coroutine.
32
34
/* *
@@ -53,26 +55,6 @@ template <typename Handler>
53
55
class basic_stackless_context
54
56
{
55
57
public:
56
- // / Construct a coroutine context to represent the specified coroutine.
57
- /* *
58
- * Most applications do not need to use this constructor. Instead, the go()
59
- * function passes a coroutine context as an argument to the coroutine
60
- * function.
61
- */
62
- basic_stackless_context (
63
- const detail::shared_ptr<
64
- detail::stackless_impl_base<Handler> >& stackless_impl,
65
- Handler& handler, coroutine* coro,
66
- asio::error_code* throw_ec, void ** result)
67
- : stackless_impl_(stackless_impl),
68
- handler_ (handler),
69
- coroutine_(coro),
70
- throw_ec_(throw_ec),
71
- async_result_(result),
72
- ec_(throw_ec)
73
- {
74
- }
75
-
76
58
// / Return a coroutine context that sets the specified error_code.
77
59
/* *
78
60
* By default, when a coroutine context is used with an asynchronous operation, a
@@ -102,78 +84,10 @@ class basic_stackless_context
102
84
return tmp;
103
85
}
104
86
105
- // / Returns true if the coroutine is the child of a fork.
106
- bool is_child () const
107
- {
108
- return coroutine_->is_child ();
109
- }
110
-
111
- // / Returns true if the coroutine is the parent of a fork.
112
- bool is_parent () const
113
- {
114
- return !is_child ();
115
- }
116
-
117
- // / Returns true if the coroutine has reached its terminal state.
118
- bool is_complete () const
119
- {
120
- return coroutine_->is_complete ();
121
- }
122
-
123
- // / Used by the @c reenter pseudo-keyword to obtain the coroutine state.
124
- friend coroutine& get_coroutine (basic_stackless_context& c)
125
- {
126
- return *c.coroutine_ ;
127
- }
128
-
129
- // / Used by the @c reenter pseudo-keyword to obtain the coroutine state.
130
- friend coroutine& get_coroutine (basic_stackless_context* c)
131
- {
132
- return *c->coroutine_ ;
133
- }
134
-
135
- // / Used by the @c reenter pseudo-keyword to obtain the error code resulting
136
- // / from the previous operation. If set, an exception will be thrown
137
- // / immediately following the resumption point.
138
- friend const asio::error_code* get_coroutine_error (
139
- basic_stackless_context& c)
140
- {
141
- return c.throw_ec_ ;
142
- }
143
-
144
- // / Used by the @c reenter pseudo-keyword to obtain the error code resulting
145
- // / from the previous operation. If set, an exception will be thrown
146
- // / immediately following the resumption point.
147
- friend const asio::error_code* get_coroutine_error (
148
- basic_stackless_context* c)
149
- {
150
- return c->throw_ec_ ;
151
- }
152
-
153
- // / Called by the @c let and @c await pseudo-keywords to obtain the pointer
154
- // / used to refer to any variables that should be set from the result of an
155
- // / asynchronous operation.
156
- friend void ** get_coroutine_async_result (basic_stackless_context& c)
157
- {
158
- return c.async_result_ ;
159
- }
160
-
161
- // / Called by the @c let and @c await pseudo-keywords to obtain the pointer
162
- // / used to refer to any variables that should be set from the result of an
163
- // / asynchronous operation.
164
- friend void ** get_coroutine_async_result (basic_stackless_context* c)
165
- {
166
- return c->async_result_ ;
167
- }
168
-
169
87
#if defined(GENERATING_DOCUMENTATION)
170
88
private:
171
89
#endif // defined(GENERATING_DOCUMENTATION)
172
- detail::shared_ptr<detail::stackless_impl_base<Handler> > stackless_impl_;
173
- Handler& handler_;
174
- coroutine* coroutine_;
175
- const asio::error_code* const throw_ec_;
176
- void ** const async_result_;
90
+ detail::stackless_impl_base<Handler>** impl_;
177
91
asio::error_code* ec_;
178
92
};
179
93
0 commit comments