LCOV - code coverage report
Current view: top level - envoy/init - watcher.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 2 2 100.0 %
Date: 2024-01-05 06:35:25 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <memory>
       4             : 
       5             : #include "envoy/common/pure.h"
       6             : 
       7             : #include "absl/strings/string_view.h"
       8             : 
       9             : namespace Envoy {
      10             : namespace Init {
      11             : 
      12             : /**
      13             :  * A WatcherHandle functions as a weak reference to a Watcher. It is how an implementation of
      14             :  * Init::Target would safely notify a Manager that it has initialized, and likewise it's how
      15             :  * an implementation of Init::Manager would safely tell its client that all registered targets
      16             :  * have initialized, with no guarantees about the lifetimes of the manager or client. Typical usage
      17             :  * (outside of Init::TargetImpl and ManagerImpl) does not require touching WatcherHandles at
      18             :  * all.
      19             :  */
      20             : struct WatcherHandle {
      21         863 :   virtual ~WatcherHandle() = default;
      22             : 
      23             :   /**
      24             :    * Tell the watcher that initialization has completed, if it is still available.
      25             :    * @return true if the watcher received this call, false if the watcher was already destroyed.
      26             :    */
      27             :   virtual bool ready() const PURE;
      28             : };
      29             : using WatcherHandlePtr = std::unique_ptr<WatcherHandle>;
      30             : 
      31             : /**
      32             :  * A Watcher is an entity that listens for notifications that either an initialization target or
      33             :  * all targets registered with a manager have initialized. It can only be invoked through a
      34             :  * WatcherHandle.
      35             :  */
      36             : struct Watcher {
      37        3884 :   virtual ~Watcher() = default;
      38             : 
      39             :   /**
      40             :    * @return a human-readable target name, for logging / debugging.
      41             :    */
      42             :   virtual absl::string_view name() const PURE;
      43             : 
      44             :   /**
      45             :    * Create a new handle that can notify this watcher.
      46             :    * @param name a human readable handle name, for logging / debugging.
      47             :    * @return a new handle that can notify this watcher.
      48             :    */
      49             :   virtual WatcherHandlePtr createHandle(absl::string_view name) const PURE;
      50             : };
      51             : 
      52             : } // namespace Init
      53             : } // namespace Envoy

Generated by: LCOV version 1.15