18
18
#include " asio/detail/config.hpp"
19
19
#include " asio/coroutine.hpp"
20
20
#include " asio/detail/variadic_templates.hpp"
21
- #include " asio/detail/wrapped_handler.hpp"
22
21
#include " asio/io_service.hpp"
23
22
#include " asio/strand.hpp"
24
23
@@ -49,12 +48,12 @@ template <typename Handler, typename Signature> class stackless_impl_base;
49
48
50
49
// / Context object the represents the currently executing coroutine.
51
50
/* *
52
- * The basic_stackless_context class is used to represent the currently
53
- * executing stackless coroutine. A basic_stackless_context may be passed as a
54
- * handler to an asynchronous operation. For example:
51
+ * The stackless_context class is used to represent the currently executing
52
+ * stackless coroutine. A stackless_context may be passed as a handler to an
53
+ * asynchronous operation. For example:
55
54
*
56
55
* @code template <typename Handler>
57
- * void my_coroutine(basic_stackless_context <Handler> ctx)
56
+ * void my_coroutine(stackless_context <Handler> ctx)
58
57
* {
59
58
* reenter (ctx)
60
59
* {
@@ -68,8 +67,8 @@ template <typename Handler, typename Signature> class stackless_impl_base;
68
67
* the current coroutine. The coroutine is resumed when the asynchronous
69
68
* operation completes.
70
69
*/
71
- template <typename Handler, typename Signature = void ()>
72
- class basic_stackless_context
70
+ template <typename Handler = void , typename Signature = void ()>
71
+ class stackless_context
73
72
{
74
73
public:
75
74
// / Return a coroutine context that sets the specified error_code.
@@ -80,7 +79,7 @@ class basic_stackless_context
80
79
* set with the asynchronous operation's result. For example:
81
80
*
82
81
* @code template <typename Handler>
83
- * void my_coroutine(basic_stackless_context <Handler> ctx)
82
+ * void my_coroutine(stackless_context <Handler> ctx)
84
83
* {
85
84
* reenter (ctx)
86
85
* {
@@ -94,9 +93,9 @@ class basic_stackless_context
94
93
* }
95
94
* } @endcode
96
95
*/
97
- basic_stackless_context operator [](asio::error_code& ec) const
96
+ stackless_context operator [](asio::error_code& ec) const
98
97
{
99
- basic_stackless_context tmp (*this );
98
+ stackless_context tmp (*this );
100
99
tmp.ec_ = &ec;
101
100
return tmp;
102
101
}
@@ -106,10 +105,6 @@ class basic_stackless_context
106
105
* This function is used to invoke the coroutine's associated completion
107
106
* handler. It should be called at most once, immediately prior to the
108
107
* termination of the coroutine. Additional calls will be ignored.
109
- *
110
- * For completion handlers with the signature <tt>void()</tt>, and if @c
111
- * complete() is not explicitly called, the completion handler will be
112
- * automatically invoked after coroutine termination.
113
108
*/
114
109
#if defined(GENERATING_DOCUMENTATION) \
115
110
|| defined(ASIO_HAS_VARIADIC_TEMPLATES)
@@ -129,16 +124,6 @@ class basic_stackless_context
129
124
asio::error_code* ec_;
130
125
};
131
126
132
- #if defined(GENERATING_DOCUMENTATION)
133
- // / Context object that represents the currently executing coroutine.
134
- typedef basic_stackless_context<unspecified> stackless_context;
135
- #else // defined(GENERATING_DOCUMENTATION)
136
- typedef basic_stackless_context<
137
- detail::wrapped_handler<
138
- io_service::strand, void (*)(),
139
- detail::is_continuation_if_running> > stackless_context;
140
- #endif // defined(GENERATING_DOCUMENTATION)
141
-
142
127
/* *
143
128
* @defgroup go asio::go
144
129
*
@@ -181,19 +166,28 @@ typedef basic_stackless_context<
181
166
*/
182
167
/* @{*/
183
168
169
+ // / Start a new stackless coroutine.
170
+ /* *
171
+ * This function is used to launch a new coroutine.
172
+ *
173
+ * @param function The coroutine function. The function must have the signature:
174
+ * @code void function(stackless_context<void> c); @endcode
175
+ */
176
+ template <typename Function>
177
+ void go (ASIO_MOVE_ARG(Function) function);
178
+
184
179
// / Start a new stackless coroutine with an associated completion handler.
185
180
/* *
186
181
* This function is used to launch a new coroutine.
187
182
*
188
183
* @param handler The handler associated with the coroutine. The handler may be
189
- * explicitly called via the context's @c complete() function, but will be
190
- * invoked automatically after coroutine termination if not called first. More
184
+ * explicitly called via the context's @c complete() function. More
191
185
* importantly, the handler provides an execution context (via the the handler
192
186
* invocation hook) for the coroutine. The handler must have the signature:
193
187
* @code void handler(); @endcode
194
188
*
195
189
* @param function The coroutine function. The function must have the signature:
196
- * @code void function(basic_stackless_context <Handler> c); @endcode
190
+ * @code void function(stackless_context <Handler> c); @endcode
197
191
*/
198
192
template <typename Handler, typename Function>
199
193
ASIO_INITFN_RESULT_TYPE (Handler, void ())
@@ -210,7 +204,7 @@ go(ASIO_MOVE_ARG(Handler) handler,
210
204
* for the coroutine.
211
205
*
212
206
* @param function The coroutine function. The function must have the signature:
213
- * @code void function(basic_stackless_context <Handler, Signature> c); @endcode
207
+ * @code void function(stackless_context <Handler, Signature> c); @endcode
214
208
*/
215
209
template <typename Signature, typename Handler, typename Function>
216
210
ASIO_INITFN_RESULT_TYPE (Handler, Signature)
@@ -228,10 +222,10 @@ go(ASIO_MOVE_ARG(Handler) handler,
228
222
* same strand.
229
223
*
230
224
* @param function The coroutine function. The function must have the signature:
231
- * @code void function(basic_stackless_context <Handler> yield); @endcode
225
+ * @code void function(stackless_context <Handler> yield); @endcode
232
226
*/
233
227
template <typename Handler, typename Function>
234
- void go (basic_stackless_context <Handler> ctx,
228
+ void go (stackless_context <Handler> ctx,
235
229
ASIO_MOVE_ARG (Function) function);
236
230
237
231
// / Start a new stackless coroutine that executes in the context of a strand.
@@ -243,7 +237,7 @@ void go(basic_stackless_context<Handler> ctx,
243
237
* execute simultaneously.
244
238
*
245
239
* @param function The coroutine function. The function must have the signature:
246
- * @code void function(stackless_context yield); @endcode
240
+ * @code void function(stackless_context<io_service::strand> yield); @endcode
247
241
*/
248
242
template <typename Function>
249
243
void go (asio::io_service::strand strand,
@@ -253,11 +247,10 @@ void go(asio::io_service::strand strand,
253
247
/* *
254
248
* This function is used to launch a new coroutine.
255
249
*
256
- * @param io_service Identifies the io_service that will run the coroutine. The
257
- * new coroutine is implicitly given its own strand within this io_service.
250
+ * @param io_service Identifies the io_service that will run the coroutine.
258
251
*
259
252
* @param function The coroutine function. The function must have the signature:
260
- * @code void function(stackless_context yield); @endcode
253
+ * @code void function(stackless_context<io_service> yield); @endcode
261
254
*/
262
255
template <typename Function>
263
256
void go (asio::io_service& io_service,
0 commit comments