...
This commit is contained in:
@@ -69,7 +69,7 @@ concept adc_asio_is_awaitable = requires {
|
||||
|
||||
|
||||
template <typename T>
|
||||
concept adc_asio_special_comp_token =
|
||||
concept adc_asio_special_comp_token_c =
|
||||
adc_asio_is_future<T> || adc_asio_is_awaitable<T> || std::same_as<std::remove_cvref_t<T>, asio::deferred_t>;
|
||||
|
||||
|
||||
@@ -198,6 +198,18 @@ public:
|
||||
}
|
||||
|
||||
|
||||
AdcNetServiceASIOBase(AdcNetServiceASIOBase&& other)
|
||||
: _ioContext(other._ioContext),
|
||||
_receiveStrand(std::move(other._receiveStrand)),
|
||||
_receiveQueue(std::move(_receiveQueue)),
|
||||
_acceptor(std::move(other._acceptor)),
|
||||
_socket(std::move(other._socket)),
|
||||
_streamBuffer()
|
||||
{
|
||||
auto bytes = asio::buffer_copy(_streamBuffer.prepare(other._streamBuffer.size()), other._streamBuffer.data());
|
||||
_streamBuffer.commit(bytes);
|
||||
};
|
||||
|
||||
AdcNetServiceASIOBase(const AdcNetServiceASIOBase&) = delete; // no copy constructor!
|
||||
|
||||
virtual ~AdcNetServiceASIOBase() {}
|
||||
@@ -336,7 +348,7 @@ public:
|
||||
constexpr auto is_async_ctx_t = std::same_as<std::remove_cvref_t<TokenT>, async_call_ctx_t>;
|
||||
|
||||
// check completion token signature and deduce message type
|
||||
if constexpr (!adc_asio_special_comp_token<TokenT> && !is_async_ctx_t) {
|
||||
if constexpr (!adc_asio_special_comp_token_c<TokenT> && !is_async_ctx_t) {
|
||||
static_assert(traits::adc_func_traits<TokenT>::arity == 2, "INVALID COMPLETION TOKEN SIGNATURE!");
|
||||
static_assert(std::is_same_v<std::remove_cvref_t<traits::adc_func_arg1_t<TokenT>>, std::error_code>,
|
||||
"INVALID COMPLETION TOKEN SIGNATURE!");
|
||||
@@ -346,7 +358,7 @@ public:
|
||||
}
|
||||
|
||||
using msg_t = std::conditional_t<
|
||||
adc_asio_special_comp_token<TokenT> || is_async_ctx_t, RMSGT,
|
||||
adc_asio_special_comp_token_c<TokenT> || is_async_ctx_t, RMSGT,
|
||||
std::remove_cvref_t<std::tuple_element_t<1, typename traits::adc_func_traits<TokenT>::args_t>>>;
|
||||
|
||||
// auto s_res = std::make_shared<std::invoke_result_t<decltype(this->template search<RMSGT>), RMSGT>>();
|
||||
@@ -595,15 +607,19 @@ protected:
|
||||
const TimeoutT& timeout,
|
||||
bool arm = true)
|
||||
{
|
||||
// TODO: now()+timeout overflow!!!
|
||||
auto timer = std::make_unique<asio::steady_timer>(obj.get_executor());
|
||||
|
||||
if (timeout == std::chrono::duration<typename TimeoutT::rep, typename TimeoutT::period>::max()) {
|
||||
return timer; // do not arm the timer if MAX duration are given
|
||||
}
|
||||
// if (timeout == std::chrono::duration<typename TimeoutT::rep, typename TimeoutT::period>::max()) {
|
||||
// return timer; // do not arm the timer if MAX duration are given
|
||||
// }
|
||||
|
||||
if (arm) {
|
||||
timer->expires_after(timeout);
|
||||
std::chrono::seconds max_d = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::steady_clock::time_point::max() - std::chrono::steady_clock::now() -
|
||||
std::chrono::seconds(1));
|
||||
|
||||
timer->expires_after(timeout < max_d ? timeout : max_d); // to avoid overflow!
|
||||
// timer->expires_after(timeout);
|
||||
|
||||
timer->async_wait([&obj](const std::error_code& ec) mutable {
|
||||
if (!ec) {
|
||||
|
||||
Reference in New Issue
Block a user