Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : 5 : namespace Envoy { 6 : namespace Event { 7 : 8 : /** 9 : * If an object derives from this class, it can be passed to the dispatcher who guarantees to delete 10 : * it in a future event loop cycle. This allows clear ownership with unique_ptr while not having 11 : * to worry about stack unwind issues during event processing. 12 : */ 13 : class DeferredDeletable { 14 : public: 15 13442 : virtual ~DeferredDeletable() = default; 16 : 17 : /** 18 : * Called when an object is passed to `deferredDelete`. This signals that the object will soon 19 : * be deleted. 20 : */ 21 4761 : virtual void deleteIsPending() {} 22 : }; 23 : 24 : using DeferredDeletablePtr = std::unique_ptr<DeferredDeletable>; 25 : 26 : } // namespace Event 27 : } // namespace Envoy