5#include <userver/engine/semaphore.hpp> 
   20class SemaphoreCapacityControl 
final {
 
   22  using Counter = engine::Semaphore::Counter;
 
   23  static constexpr Counter kOverrideDisabled = -1;
 
   25  explicit SemaphoreCapacityControl(engine::CancellableSemaphore& semaphore);
 
   28  void SetCapacity(Counter capacity);
 
   29  Counter GetCapacity() 
const noexcept;
 
   33  void SetCapacityOverride(Counter capacity);
 
   34  void RemoveCapacityOverride();
 
   37  void UpdateSemaphoreCapacity() 
const;
 
   39  engine::CancellableSemaphore& semaphore_;
 
   40  std::atomic<Counter> capacity_requested_;
 
   41  std::atomic<Counter> capacity_override_{kOverrideDisabled};