mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 08:46:44 +08:00
Rename cti::asio_token to cti::use_continuable
* support -> external
This commit is contained in:
parent
1a1c7b68c6
commit
89031d932c
@ -31,7 +31,7 @@
|
|||||||
#include <asio.hpp>
|
#include <asio.hpp>
|
||||||
|
|
||||||
#include <continuable/continuable.hpp>
|
#include <continuable/continuable.hpp>
|
||||||
#include <continuable/support/asio.hpp>
|
#include <continuable/external/asio.hpp>
|
||||||
|
|
||||||
// Queries the NIST daytime service and prints the current date and time
|
// Queries the NIST daytime service and prints the current date and time
|
||||||
void daytime_service();
|
void daytime_service();
|
||||||
@ -61,13 +61,13 @@ void daytime_service() {
|
|||||||
tcp::socket socket(ioc);
|
tcp::socket socket(ioc);
|
||||||
std::string buf;
|
std::string buf;
|
||||||
|
|
||||||
resolver.async_resolve("time.nist.gov", "daytime", cti::asio_token)
|
resolver.async_resolve("time.nist.gov", "daytime", cti::use_continuable)
|
||||||
.then([&socket](tcp::resolver::results_type endpoints) {
|
.then([&socket](tcp::resolver::results_type endpoints) {
|
||||||
return asio::async_connect(socket, endpoints, cti::asio_token);
|
return asio::async_connect(socket, endpoints, cti::use_continuable);
|
||||||
})
|
})
|
||||||
.then([&socket, &buf] {
|
.then([&socket, &buf] {
|
||||||
return asio::async_read_until(socket, asio::dynamic_buffer(buf), '\n',
|
return asio::async_read_until(socket, asio::dynamic_buffer(buf), '\n',
|
||||||
cti::asio_token);
|
cti::use_continuable);
|
||||||
})
|
})
|
||||||
.then([&buf](std::size_t) { puts(buf.data()); })
|
.then([&buf](std::size_t) { puts(buf.data()); })
|
||||||
.fail(&unexpected_error);
|
.fail(&unexpected_error);
|
||||||
@ -81,7 +81,7 @@ void cancelled_async_wait() {
|
|||||||
|
|
||||||
t.expires_after(std::chrono::seconds(999));
|
t.expires_after(std::chrono::seconds(999));
|
||||||
|
|
||||||
t.async_wait(cti::asio_token)
|
t.async_wait(cti::use_continuable)
|
||||||
.then([] {
|
.then([] {
|
||||||
puts("This should never be called");
|
puts("This should never be called");
|
||||||
std::terminate();
|
std::terminate();
|
||||||
|
|||||||
@ -132,14 +132,13 @@ struct initiate_make_continuable;
|
|||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
struct initiate_make_continuable<void(error_code_t, Args...)> {
|
struct initiate_make_continuable<void(error_code_t, Args...)> {
|
||||||
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
||||||
using erased_return_type = cti::continuable<Args...>;
|
using erased_return_type = continuable<Args...>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename Continuation>
|
template <typename Continuation>
|
||||||
auto operator()(Continuation&& continuation) {
|
auto operator()(Continuation&& continuation) {
|
||||||
return detail::base::attorney::create_from(
|
return base::attorney::create_from(std::forward<Continuation>(continuation),
|
||||||
std::forward<Continuation>(continuation), detail::identity<Args...>{},
|
identity<Args...>{}, util::ownership{});
|
||||||
detail::util::ownership{});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -27,28 +27,26 @@
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef CONTINUABLE_SUPPORT_ASIO_HPP_INCLUDED
|
#ifndef CONTINUABLE_EXTERNAL_ASIO_HPP_INCLUDED
|
||||||
#define CONTINUABLE_SUPPORT_ASIO_HPP_INCLUDED
|
#define CONTINUABLE_EXTERNAL_ASIO_HPP_INCLUDED
|
||||||
|
|
||||||
#include <continuable/continuable-base.hpp>
|
#include <continuable/continuable-base.hpp>
|
||||||
#include <continuable/detail/support/asio.hpp>
|
#include <continuable/detail/external/asio.hpp>
|
||||||
#include <continuable/detail/utility/traits.hpp>
|
#include <continuable/detail/utility/traits.hpp>
|
||||||
|
|
||||||
namespace cti {
|
namespace cti {
|
||||||
|
/// Type used as an ASIO completion token to specify an asynchronous operation
|
||||||
|
/// should return a continuable.
|
||||||
|
struct use_continuable_t {};
|
||||||
|
|
||||||
// Type used as an ASIO completion token to specify an asynchronous operation
|
/// Special value for instance of `asio_token_t`.
|
||||||
// should return a continuable.
|
constexpr use_continuable_t use_continuable{};
|
||||||
struct asio_token_t {};
|
|
||||||
|
|
||||||
// Special value for instance of `asio_token_t`.
|
|
||||||
constexpr asio_token_t asio_token{};
|
|
||||||
|
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
CTI_DETAIL_ASIO_NAMESPACE_BEGIN
|
CTI_DETAIL_ASIO_NAMESPACE_BEGIN
|
||||||
|
|
||||||
template <typename Signature>
|
template <typename Signature>
|
||||||
class async_result<cti::asio_token_t, Signature> {
|
class async_result<cti::use_continuable_t, Signature> {
|
||||||
public:
|
public:
|
||||||
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
||||||
using return_type = typename cti::detail::asio::initiate_make_continuable<
|
using return_type = typename cti::detail::asio::initiate_make_continuable<
|
||||||
@ -56,7 +54,8 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename Initiation, typename... Args>
|
template <typename Initiation, typename... Args>
|
||||||
static auto initiate(Initiation initiation, cti::asio_token_t, Args... args) {
|
static auto initiate(Initiation initiation, cti::use_continuable_t,
|
||||||
|
Args... args) {
|
||||||
return cti::detail::asio::initiate_make_continuable<Signature>{}(
|
return cti::detail::asio::initiate_make_continuable<Signature>{}(
|
||||||
[initiation = std::move(initiation),
|
[initiation = std::move(initiation),
|
||||||
init_args =
|
init_args =
|
||||||
@ -80,4 +79,4 @@ CTI_DETAIL_ASIO_NAMESPACE_END
|
|||||||
#undef CTI_DETAIL_ASIO_NAMESPACE_END
|
#undef CTI_DETAIL_ASIO_NAMESPACE_END
|
||||||
#undef CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION
|
#undef CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION
|
||||||
|
|
||||||
#endif // CONTINUABLE_SUPPORT_ASIO_HPP_INCLUDED
|
#endif // CONTINUABLE_EXTERNAL_ASIO_HPP_INCLUDED
|
||||||
@ -28,8 +28,8 @@
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef CONTINUABLE_SUPPORT_GTEST_HPP_INCLUDED
|
#ifndef CONTINUABLE_EXTERNAL_GTEST_HPP_INCLUDED
|
||||||
#define CONTINUABLE_SUPPORT_GTEST_HPP_INCLUDED
|
#define CONTINUABLE_EXTERNAL_GTEST_HPP_INCLUDED
|
||||||
|
|
||||||
#include <continuable/detail/other/testing.hpp>
|
#include <continuable/detail/other/testing.hpp>
|
||||||
#include <continuable/detail/utility/traits.hpp>
|
#include <continuable/detail/utility/traits.hpp>
|
||||||
@ -169,4 +169,4 @@
|
|||||||
|
|
||||||
/// \}
|
/// \}
|
||||||
|
|
||||||
#endif // CONTINUABLE_SUPPORT_GTEST_HPP_INCLUDED
|
#endif // CONTINUABLE_EXTERNAL_GTEST_HPP_INCLUDED
|
||||||
@ -15,6 +15,7 @@ group_sources(${CMAKE_CURRENT_LIST_DIR}
|
|||||||
target_link_libraries(test-playground
|
target_link_libraries(test-playground
|
||||||
PRIVATE
|
PRIVATE
|
||||||
gtest
|
gtest
|
||||||
|
asio
|
||||||
continuable
|
continuable
|
||||||
continuable-features-flags
|
continuable-features-flags
|
||||||
continuable-features-warnings
|
continuable-features-warnings
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user