LCOV - code coverage report
Current view: top level - datadog - event_scheduler.h (source / functions) Hit Total Coverage
Test: filtered.info Lines: 1 1 100.0 %
Date: 2024-01-03 20:30:12 Functions: 1 2 50.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : // This component provides an interface, `EventScheduler`, that allows a
       4             : // specified function-like object to be invoked at regular intervals.
       5             : //
       6             : // `DatadogAgent` uses an `EventScheduler` to periodically send batches of
       7             : // traces to the Datadog Agent.
       8             : //
       9             : // The default implementation is `ThreadedEventScheduler`.  See
      10             : // `threaded_event_scheduler.h`.
      11             : 
      12             : #include <chrono>
      13             : #include <functional>
      14             : 
      15             : #include "error.h"
      16             : #include "json_fwd.hpp"
      17             : 
      18             : namespace datadog {
      19             : namespace tracing {
      20             : 
      21             : class EventScheduler {
      22             :  public:
      23             :   using Cancel = std::function<void()>;
      24             : 
      25             :   // Invoke the specified `callback` repeatedly, with the specified `interval`
      26             :   // elapsing between invocations.  The first invocation is after an initial
      27             :   // `interval`.  Return a function-like object that can be invoked without
      28             :   // arguments to prevent subsequent invocations of `callback`.
      29             :   virtual Cancel schedule_recurring_event(
      30             :       std::chrono::steady_clock::duration interval,
      31             :       std::function<void()> callback) = 0;
      32             : 
      33             :   // Return a JSON representation of this object's configuration. The JSON
      34             :   // representation is an object with the following properties:
      35             :   //
      36             :   // - "type" is the unmangled, qualified name of the most-derived class, e.g.
      37             :   //   "datadog::tracing::ThreadedEventScheduler".
      38             :   // - "config" is an object containing this object's configuration. "config"
      39             :   //   may be omitted if the derived class has no configuration.
      40             :   virtual nlohmann::json config_json() const = 0;
      41             : 
      42         619 :   virtual ~EventScheduler() = default;
      43             : };
      44             : 
      45             : }  // namespace tracing
      46             : }  // namespace datadog

Generated by: LCOV version 1.16