Skip to content

Commit 97c5225

Browse files
committed
Rename basic_stackless_context to stackless_context and make the
use of the template parameters explicit.
1 parent 58fe1c7 commit 97c5225

File tree

3 files changed

+110
-94
lines changed

3 files changed

+110
-94
lines changed

asio/include/asio/go.hpp

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "asio/detail/config.hpp"
1919
#include "asio/coroutine.hpp"
2020
#include "asio/detail/variadic_templates.hpp"
21-
#include "asio/detail/wrapped_handler.hpp"
2221
#include "asio/io_service.hpp"
2322
#include "asio/strand.hpp"
2423

@@ -49,12 +48,12 @@ template <typename Handler, typename Signature> class stackless_impl_base;
4948

5049
/// Context object the represents the currently executing coroutine.
5150
/**
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:
5554
*
5655
* @code template <typename Handler>
57-
* void my_coroutine(basic_stackless_context<Handler> ctx)
56+
* void my_coroutine(stackless_context<Handler> ctx)
5857
* {
5958
* reenter (ctx)
6059
* {
@@ -68,8 +67,8 @@ template <typename Handler, typename Signature> class stackless_impl_base;
6867
* the current coroutine. The coroutine is resumed when the asynchronous
6968
* operation completes.
7069
*/
71-
template <typename Handler, typename Signature = void ()>
72-
class basic_stackless_context
70+
template <typename Handler = void, typename Signature = void ()>
71+
class stackless_context
7372
{
7473
public:
7574
/// Return a coroutine context that sets the specified error_code.
@@ -80,7 +79,7 @@ class basic_stackless_context
8079
* set with the asynchronous operation's result. For example:
8180
*
8281
* @code template <typename Handler>
83-
* void my_coroutine(basic_stackless_context<Handler> ctx)
82+
* void my_coroutine(stackless_context<Handler> ctx)
8483
* {
8584
* reenter (ctx)
8685
* {
@@ -94,9 +93,9 @@ class basic_stackless_context
9493
* }
9594
* } @endcode
9695
*/
97-
basic_stackless_context operator[](asio::error_code& ec) const
96+
stackless_context operator[](asio::error_code& ec) const
9897
{
99-
basic_stackless_context tmp(*this);
98+
stackless_context tmp(*this);
10099
tmp.ec_ = &ec;
101100
return tmp;
102101
}
@@ -106,10 +105,6 @@ class basic_stackless_context
106105
* This function is used to invoke the coroutine's associated completion
107106
* handler. It should be called at most once, immediately prior to the
108107
* 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.
113108
*/
114109
#if defined(GENERATING_DOCUMENTATION) \
115110
|| defined(ASIO_HAS_VARIADIC_TEMPLATES)
@@ -129,16 +124,6 @@ class basic_stackless_context
129124
asio::error_code* ec_;
130125
};
131126

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-
142127
/**
143128
* @defgroup go asio::go
144129
*
@@ -181,19 +166,28 @@ typedef basic_stackless_context<
181166
*/
182167
/*@{*/
183168

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+
184179
/// Start a new stackless coroutine with an associated completion handler.
185180
/**
186181
* This function is used to launch a new coroutine.
187182
*
188183
* @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
191185
* importantly, the handler provides an execution context (via the the handler
192186
* invocation hook) for the coroutine. The handler must have the signature:
193187
* @code void handler(); @endcode
194188
*
195189
* @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
197191
*/
198192
template <typename Handler, typename Function>
199193
ASIO_INITFN_RESULT_TYPE(Handler, void ())
@@ -210,7 +204,7 @@ go(ASIO_MOVE_ARG(Handler) handler,
210204
* for the coroutine.
211205
*
212206
* @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
214208
*/
215209
template <typename Signature, typename Handler, typename Function>
216210
ASIO_INITFN_RESULT_TYPE(Handler, Signature)
@@ -228,10 +222,10 @@ go(ASIO_MOVE_ARG(Handler) handler,
228222
* same strand.
229223
*
230224
* @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
232226
*/
233227
template <typename Handler, typename Function>
234-
void go(basic_stackless_context<Handler> ctx,
228+
void go(stackless_context<Handler> ctx,
235229
ASIO_MOVE_ARG(Function) function);
236230

237231
/// Start a new stackless coroutine that executes in the context of a strand.
@@ -243,7 +237,7 @@ void go(basic_stackless_context<Handler> ctx,
243237
* execute simultaneously.
244238
*
245239
* @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
247241
*/
248242
template <typename Function>
249243
void go(asio::io_service::strand strand,
@@ -253,11 +247,10 @@ void go(asio::io_service::strand strand,
253247
/**
254248
* This function is used to launch a new coroutine.
255249
*
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.
258251
*
259252
* @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
261254
*/
262255
template <typename Function>
263256
void go(asio::io_service& io_service,

0 commit comments

Comments
 (0)