1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*-
2 // vim: ts=8 sw=2 smarttab expandtab
6 #include "include/types.h"
7 #include "crimson/common/errorator.h"
8 #include "crimson/common/exception.h"
9 #include "crimson/common/type_helpers.h"
11 namespace crimson::osd
{
15 class IOInterruptCondition
{
17 IOInterruptCondition(Ref
<PG
>& pg
);
18 ~IOInterruptCondition();
20 bool new_interval_created();
26 template <typename Fut
>
27 std::pair
<bool, std::optional
<Fut
>> may_interrupt() {
28 if (new_interval_created()) {
29 return {true, seastar::futurize
<Fut
>::make_exception_future(
30 ::crimson::common::actingset_changed(is_primary()))};
33 return {true, seastar::futurize
<Fut
>::make_exception_future(
34 ::crimson::common::system_shutdown_exception())};
36 return {false, std::optional
<Fut
>()};
40 static constexpr bool is_interruption_v
=
41 std::is_same_v
<T
, ::crimson::common::actingset_changed
>
42 || std::is_same_v
<T
, ::crimson::common::system_shutdown_exception
>;
44 static bool is_interruption(std::exception_ptr
& eptr
) {
45 return (*eptr
.__cxa_exception_type() ==
46 typeid(::crimson::common::actingset_changed
) ||
47 *eptr
.__cxa_exception_type() ==
48 typeid(::crimson::common::system_shutdown_exception
));
56 } // namespace crimson::osd