diff --git a/BUILD b/BUILD index 879aec8d0c4..25bd67ec8a1 100644 --- a/BUILD +++ b/BUILD @@ -2312,6 +2312,7 @@ grpc_cc_library( "src/core/lib/event_engine/iomgr_engine/iomgr_engine_closure.h", ], external_deps = [ + "absl/functional:any_invocable", "absl/status", "absl/utility", ], diff --git a/src/core/lib/event_engine/iomgr_engine/iomgr_engine_closure.h b/src/core/lib/event_engine/iomgr_engine/iomgr_engine_closure.h index 60dacae492a..9716c8eae6c 100644 --- a/src/core/lib/event_engine/iomgr_engine/iomgr_engine_closure.h +++ b/src/core/lib/event_engine/iomgr_engine/iomgr_engine_closure.h @@ -16,9 +16,9 @@ #define GRPC_CORE_LIB_EVENT_ENGINE_IOMGR_ENGINE_IOMGR_ENGINE_CLOSURE_H #include -#include #include +#include "absl/functional/any_invocable.h" #include "absl/status/status.h" #include "absl/utility/utility.h" @@ -35,7 +35,8 @@ class IomgrEngineClosure final : public grpc_event_engine::experimental::EventEngine::Closure { public: IomgrEngineClosure() = default; - IomgrEngineClosure(std::function&& cb, bool is_permanent) + IomgrEngineClosure(absl::AnyInvocable cb, + bool is_permanent) : cb_(std::move(cb)), is_permanent_(is_permanent), status_(absl::OkStatus()) {} @@ -51,19 +52,19 @@ class IomgrEngineClosure final // This closure clean doesn't itself up after execution. It is expected to be // cleaned up by the caller at the appropriate time. static IomgrEngineClosure* ToPermanentClosure( - std::function&& cb) { + absl::AnyInvocable cb) { return new IomgrEngineClosure(std::move(cb), true); } // This closure clean's itself up after execution. It is expected to be // used only in tests. static IomgrEngineClosure* TestOnlyToClosure( - std::function&& cb) { + absl::AnyInvocable cb) { return new IomgrEngineClosure(std::move(cb), false); } private: - std::function cb_; + absl::AnyInvocable cb_; bool is_permanent_ = false; absl::Status status_; };