Loading...
Searching...
No Matches
helper.hpp
1/* Copyright (c) 2018-2024 Marcelo Zimbres Silva (mzimbres@gmail.com)
2 *
3 * Distributed under the Boost Software License, Version 1.0. (See
4 * accompanying file LICENSE.txt)
5 */
6
7#ifndef BOOST_REDIS_HELPER_HPP
8#define BOOST_REDIS_HELPER_HPP
9
10#include <boost/asio/cancellation_type.hpp>
11
12namespace boost::redis::detail {
13
14template <class T>
15auto is_cancelled(T const& self)
16{
17 return self.get_cancellation_state().cancelled() != asio::cancellation_type_t::none;
18}
19
20#define BOOST_REDIS_CHECK_OP0(X) \
21 if (ec || redis::detail::is_cancelled(self)) { \
22 X self.complete(!!ec ? ec : asio::error::operation_aborted); \
23 return; \
24 }
25
26#define BOOST_REDIS_CHECK_OP1(X) \
27 if (ec || redis::detail::is_cancelled(self)) { \
28 X self.complete(!!ec ? ec : asio::error::operation_aborted, {}); \
29 return; \
30 }
31
32} // namespace boost::redis::detail
33
34#endif // BOOST_REDIS_HELPER_HPP