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 <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
|
||||
void daytime_service();
|
||||
@ -61,13 +61,13 @@ void daytime_service() {
|
||||
tcp::socket socket(ioc);
|
||||
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) {
|
||||
return asio::async_connect(socket, endpoints, cti::asio_token);
|
||||
return asio::async_connect(socket, endpoints, cti::use_continuable);
|
||||
})
|
||||
.then([&socket, &buf] {
|
||||
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()); })
|
||||
.fail(&unexpected_error);
|
||||
@ -81,7 +81,7 @@ void cancelled_async_wait() {
|
||||
|
||||
t.expires_after(std::chrono::seconds(999));
|
||||
|
||||
t.async_wait(cti::asio_token)
|
||||
t.async_wait(cti::use_continuable)
|
||||
.then([] {
|
||||
puts("This should never be called");
|
||||
std::terminate();
|
||||
|
||||
@ -132,14 +132,13 @@ struct initiate_make_continuable;
|
||||
template <typename... Args>
|
||||
struct initiate_make_continuable<void(error_code_t, Args...)> {
|
||||
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
||||
using erased_return_type = cti::continuable<Args...>;
|
||||
using erased_return_type = continuable<Args...>;
|
||||
#endif
|
||||
|
||||
template <typename Continuation>
|
||||
auto operator()(Continuation&& continuation) {
|
||||
return detail::base::attorney::create_from(
|
||||
std::forward<Continuation>(continuation), detail::identity<Args...>{},
|
||||
detail::util::ownership{});
|
||||
return base::attorney::create_from(std::forward<Continuation>(continuation),
|
||||
identity<Args...>{}, util::ownership{});
|
||||
}
|
||||
};
|
||||
|
||||
@ -27,28 +27,26 @@
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifndef CONTINUABLE_SUPPORT_ASIO_HPP_INCLUDED
|
||||
#define CONTINUABLE_SUPPORT_ASIO_HPP_INCLUDED
|
||||
#ifndef CONTINUABLE_EXTERNAL_ASIO_HPP_INCLUDED
|
||||
#define CONTINUABLE_EXTERNAL_ASIO_HPP_INCLUDED
|
||||
|
||||
#include <continuable/continuable-base.hpp>
|
||||
#include <continuable/detail/support/asio.hpp>
|
||||
#include <continuable/detail/external/asio.hpp>
|
||||
#include <continuable/detail/utility/traits.hpp>
|
||||
|
||||
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
|
||||
// should return a continuable.
|
||||
struct asio_token_t {};
|
||||
|
||||
// Special value for instance of `asio_token_t`.
|
||||
constexpr asio_token_t asio_token{};
|
||||
|
||||
/// Special value for instance of `asio_token_t`.
|
||||
constexpr use_continuable_t use_continuable{};
|
||||
} // namespace cti
|
||||
|
||||
CTI_DETAIL_ASIO_NAMESPACE_BEGIN
|
||||
|
||||
template <typename Signature>
|
||||
class async_result<cti::asio_token_t, Signature> {
|
||||
class async_result<cti::use_continuable_t, Signature> {
|
||||
public:
|
||||
#if defined(CTI_DETAIL_ASIO_HAS_EXPLICIT_RET_TYPE_INTEGRATION)
|
||||
using return_type = typename cti::detail::asio::initiate_make_continuable<
|
||||
@ -56,7 +54,8 @@ public:
|
||||
#endif
|
||||
|
||||
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>{}(
|
||||
[initiation = std::move(initiation),
|
||||
init_args =
|
||||
@ -80,4 +79,4 @@ CTI_DETAIL_ASIO_NAMESPACE_END
|
||||
#undef CTI_DETAIL_ASIO_NAMESPACE_END
|
||||
#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.
|
||||
**/
|
||||
|
||||
#ifndef CONTINUABLE_SUPPORT_GTEST_HPP_INCLUDED
|
||||
#define CONTINUABLE_SUPPORT_GTEST_HPP_INCLUDED
|
||||
#ifndef CONTINUABLE_EXTERNAL_GTEST_HPP_INCLUDED
|
||||
#define CONTINUABLE_EXTERNAL_GTEST_HPP_INCLUDED
|
||||
|
||||
#include <continuable/detail/other/testing.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
|
||||
PRIVATE
|
||||
gtest
|
||||
asio
|
||||
continuable
|
||||
continuable-features-flags
|
||||
continuable-features-warnings
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user