mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 12:27:44 +02:00
Add optional yield_to arguments
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
* bjam use clang on MACOSX
|
||||
* Simplify Travis package install specification
|
||||
* Add optional yield_to arguments
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -21,9 +21,9 @@ namespace test {
|
||||
|
||||
/** Mix-in to support tests using asio coroutines.
|
||||
|
||||
Derive from this class and use yield_to to launch test functions
|
||||
inside coroutines. This is handy for testing asynchronous asio
|
||||
code.
|
||||
Derive from this class and use yield_to to launch test
|
||||
functions inside coroutines. This is handy for testing
|
||||
asynchronous asio code.
|
||||
*/
|
||||
class enable_yield_to
|
||||
{
|
||||
@ -72,12 +72,32 @@ public:
|
||||
Function will be called with this signature:
|
||||
|
||||
@code
|
||||
void f(yield_context);
|
||||
void f(args..., yield_context);
|
||||
@endcode
|
||||
|
||||
@param f The Callable object to invoke.
|
||||
|
||||
@param args Optional arguments forwarded to the callable object.
|
||||
*/
|
||||
template<class Function>
|
||||
#if GENERATING_DOCS
|
||||
template<class F, class... Args>
|
||||
void
|
||||
yield_to(Function&& f);
|
||||
yield_to(F&& f, Args&&... args);
|
||||
#else
|
||||
template<class F>
|
||||
void
|
||||
yield_to(F&& f);
|
||||
|
||||
template<class Function, class Arg, class... Args>
|
||||
void
|
||||
yield_to(Function&& f, Arg&& arg, Args&&... args)
|
||||
{
|
||||
yield_to(std::bind(f,
|
||||
std::forward<Arg>(arg),
|
||||
std::forward<Args>(args)...,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class Function>
|
||||
|
@ -132,8 +132,7 @@ public:
|
||||
{
|
||||
testSpecialMembers();
|
||||
|
||||
yield_to(std::bind(&self::testRead,
|
||||
this, std::placeholders::_1));
|
||||
yield_to(&self::testRead, this);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -378,17 +378,10 @@ public:
|
||||
{
|
||||
testThrow();
|
||||
|
||||
yield_to(std::bind(&read_test::testFailures,
|
||||
this, std::placeholders::_1));
|
||||
|
||||
yield_to(std::bind(&read_test::testReadHeaders,
|
||||
this, std::placeholders::_1));
|
||||
|
||||
yield_to(std::bind(&read_test::testRead,
|
||||
this, std::placeholders::_1));
|
||||
|
||||
yield_to(std::bind(&read_test::testEof,
|
||||
this, std::placeholders::_1));
|
||||
yield_to(&read_test::testFailures, this);
|
||||
yield_to(&read_test::testReadHeaders, this);
|
||||
yield_to(&read_test::testRead, this);
|
||||
yield_to(&read_test::testEof, this);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -702,12 +702,9 @@ public:
|
||||
|
||||
void run() override
|
||||
{
|
||||
yield_to(std::bind(&write_test::testAsyncWriteHeaders,
|
||||
this, std::placeholders::_1));
|
||||
yield_to(std::bind(&write_test::testAsyncWrite,
|
||||
this, std::placeholders::_1));
|
||||
yield_to(std::bind(&write_test::testFailures,
|
||||
this, std::placeholders::_1));
|
||||
yield_to(&write_test::testAsyncWriteHeaders, this);
|
||||
yield_to(&write_test::testAsyncWrite, this);
|
||||
yield_to(&write_test::testFailures, this);
|
||||
testOutput();
|
||||
test_std_ostream();
|
||||
testOstream();
|
||||
|
Reference in New Issue
Block a user