daemons.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright [2021] JD.com, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. #ifndef __H_WATCHDOG__H__
  18. #define __H_WATCHDOG__H__
  19. #include "unit.h"
  20. #include "poll/poller.h"
  21. #include "timer/timer_list.h"
  22. extern char daemons_cache_file[256];
  23. extern char daemons_table_file[256];
  24. class WatchDogPipe : public EpollBase
  25. {
  26. private:
  27. int peerfd_;
  28. public:
  29. WatchDogPipe();
  30. virtual ~WatchDogPipe();
  31. public:
  32. void wake();
  33. virtual void input_notify();
  34. };
  35. class WatchDog : public WatchDogUnit,
  36. public TimerUnit
  37. {
  38. private:
  39. EpollBase *listener_;
  40. public:
  41. WatchDog();
  42. virtual ~WatchDog();
  43. void set_listener(EpollBase *listener) { listener_ = listener; }
  44. void run_loop();
  45. };
  46. extern int start_dtc(int (*entry)(void *), void *);
  47. #endif