1
#pragma once
2

            
3
#include <cstdint>
4

            
5
#include "envoy/common/pure.h"
6

            
7
#include "absl/types/optional.h"
8

            
9
#pragma once
10

            
11
namespace Envoy {
12

            
13
/**
14
 * A handle for use by any resource managers.
15
 */
16
class ResourceLimit {
17
public:
18
1628781
  virtual ~ResourceLimit() = default;
19

            
20
  /**
21
   * @return true if the resource can be created.
22
   */
23
  virtual bool canCreate() PURE;
24

            
25
  /**
26
   * Increment the resource count.
27
   */
28
  virtual void inc() PURE;
29

            
30
  /**
31
   * Decrement the resource count.
32
   */
33
  virtual void dec() PURE;
34

            
35
  /**
36
   * Decrement the resource count by a specific amount.
37
   */
38
  virtual void decBy(uint64_t amount) PURE;
39

            
40
  /**
41
   * @return the current maximum allowed number of this resource.
42
   */
43
  virtual uint64_t max() PURE;
44

            
45
  /**
46
   * @return the current resource count.
47
   */
48
  virtual uint64_t count() const PURE;
49
};
50

            
51
using ResourceLimitOptRef = absl::optional<std::reference_wrapper<ResourceLimit>>;
52

            
53
} // namespace Envoy