// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*- // vim: ts=8 sw=2 smarttab expandtab #pragma once #include "include/types.h" #include "crimson/common/errorator.h" #include "crimson/common/exception.h" #include "crimson/common/type_helpers.h" namespace crimson::osd { class PG; class IOInterruptCondition { public: IOInterruptCondition(Ref& pg); ~IOInterruptCondition(); bool new_interval_created(); bool is_stopping(); bool is_primary(); template std::optional may_interrupt() { if (new_interval_created()) { return seastar::futurize::make_exception_future( ::crimson::common::actingset_changed(is_primary())); } if (is_stopping()) { return seastar::futurize::make_exception_future( ::crimson::common::system_shutdown_exception()); } return std::optional(); } template static constexpr bool is_interruption_v = std::is_same_v || std::is_same_v; static bool is_interruption(std::exception_ptr& eptr) { return (*eptr.__cxa_exception_type() == typeid(::crimson::common::actingset_changed) || *eptr.__cxa_exception_type() == typeid(::crimson::common::system_shutdown_exception)); } private: Ref pg; epoch_t e; }; } // namespace crimson::osd