Boost.Redis 1.4.2
A redis client library
Loading...
Searching...
No Matches
helper.hpp
1/* Copyright (c) 2018-2023 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{
14
15template <class T>
16auto is_cancelled(T const& self)
17{
18 return self.get_cancellation_state().cancelled() != asio::cancellation_type_t::none;
19}
20
21#define BOOST_REDIS_CHECK_OP0(X)\
22 if (ec || redis::detail::is_cancelled(self)) {\
23 X\
24 self.complete(!!ec ? ec : asio::error::operation_aborted);\
25 return;\
26 }
27
28#define BOOST_REDIS_CHECK_OP1(X)\
29 if (ec || redis::detail::is_cancelled(self)) {\
30 X\
31 self.complete(!!ec ? ec : asio::error::operation_aborted, {});\
32 return;\
33 }
34
35} // boost::redis::detail
36
37#endif // BOOST_REDIS_HELPER_HPP