Add async_op_base::invoke

This commit is contained in:
Vinnie Falco
2019-02-16 15:09:33 -08:00
parent fdaf2ea7e1
commit f41363c60c
9 changed files with 122 additions and 41 deletions
+41 -10
View File
@@ -13,6 +13,7 @@
#include "test_handler.hpp"
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/_experimental/test/handler.hpp>
#include <boost/beast/_experimental/test/stream.hpp>
#include <boost/beast/core/error.hpp>
#include <boost/asio/async_result.hpp>
@@ -419,13 +420,28 @@ public:
// invocation
{
bool invoked = false;
net::io_context ioc;
async_op_base<
final_handler,
test::handler,
net::io_context::executor_type> op(
test::any_handler(), ioc.get_executor());
op.invoke(true);
}
{
net::io_context ioc;
async_op_base<
test::handler,
net::io_context::executor_type> op(
test::any_handler(), ioc.get_executor());
op.invoke(false);
ioc.run();
}
{
async_op_base<
test::handler,
simple_executor> op(
final_handler{invoked}, {});
op.invoke();
BEAST_EXPECT(invoked);
test::any_handler(), {});
op.invoke_now();
}
// legacy hooks
@@ -478,13 +494,28 @@ public:
// invocation
{
bool invoked = false;
net::io_context ioc;
stable_async_op_base<
final_handler,
test::handler,
net::io_context::executor_type> op(
test::any_handler(), ioc.get_executor());
op.invoke(true);
}
{
net::io_context ioc;
stable_async_op_base<
test::handler,
net::io_context::executor_type> op(
test::any_handler(), ioc.get_executor());
op.invoke(false);
ioc.run();
}
{
stable_async_op_base<
test::handler,
simple_executor> op(
final_handler{invoked}, {});
op.invoke();
BEAST_EXPECT(invoked);
test::any_handler(), {});
op.invoke_now();
}
// legacy hooks
+2 -2
View File
@@ -7,8 +7,8 @@
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_TEST_HANDLER_HPP
#define BOOST_BEAST_TEST_HANDLER_HPP
#ifndef BOOST_BEAST_TEST_HANDLER_XXX_HPP
#define BOOST_BEAST_TEST_HANDLER_XXX_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>