#pragma once #include #include #include #include #include #include namespace NYT { namespace NDetail { //////////////////////////////////////////////////////////////////////////////// class IAbortable : public TThrRefBase { public: virtual void Abort() = 0; virtual TString GetType() const = 0; }; using IAbortablePtr = ::TIntrusivePtr; //////////////////////////////////////////////////////////////////////////////// class TTransactionAbortable : public IAbortable { public: TTransactionAbortable(const TClientContext& context, const TTransactionId& transactionId); void Abort() override; TString GetType() const override; private: TClientContext Context_; TTransactionId TransactionId_; }; //////////////////////////////////////////////////////////////////////////////// class TOperationAbortable : public IAbortable { public: TOperationAbortable(IClientRetryPolicyPtr clientRetryPolicy, TClientContext context, const TOperationId& operationId); void Abort() override; TString GetType() const override; private: const IClientRetryPolicyPtr ClientRetryPolicy_; const TClientContext Context_; const TOperationId OperationId_; }; //////////////////////////////////////////////////////////////////////////////// class TAbortableRegistry : public TThrRefBase { public: TAbortableRegistry() = default; static ::TIntrusivePtr Get(); void AbortAllAndBlockForever(); void Add(const TGUID& id, IAbortablePtr abortable); void Remove(const TGUID& id); private: THashMap ActiveAbortables_; TMutex Lock_; bool Running_ = true; }; //////////////////////////////////////////////////////////////////////////////// } // namespace NDetail } // namespace NYT