Line data Source code
1 : #pragma once 2 : 3 : #include <memory> 4 : 5 : #include "envoy/common/pure.h" 6 : #include "envoy/thread/thread.h" 7 : 8 : namespace Envoy { 9 : namespace Server { 10 : 11 : /** 12 : * WatchDog objects are an individual thread's interface with the deadlock 13 : * GuardDog. A shared pointer to a WatchDog is obtained from the GuardDog at 14 : * thread startup. After this point the "touch" method must be called 15 : * periodically to avoid triggering the deadlock detector. 16 : */ 17 : class WatchDog { 18 : public: 19 192 : virtual ~WatchDog() = default; 20 : 21 : /** 22 : * Manually indicate that you are still alive by calling this. 23 : * 24 : * When the watchdog is registered with a dispatcher, the dispatcher will periodically call this 25 : * method to indicate the thread is still alive. It should be called directly by the application 26 : * code in cases where the watchdog is not registered with a dispatcher. 27 : */ 28 : virtual void touch() PURE; 29 : virtual Thread::ThreadId threadId() const PURE; 30 : }; 31 : 32 : using WatchDogSharedPtr = std::shared_ptr<WatchDog>; 33 : 34 : } // namespace Server 35 : } // namespace Envoy