timeout.h 809 B

123456789101112131415161718192021222324252627
  1. #ifndef CPR_TIMEOUT_H
  2. #define CPR_TIMEOUT_H
  3. #include <chrono>
  4. #include <cstdint>
  5. namespace cpr {
  6. class Timeout {
  7. public:
  8. // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
  9. Timeout(const std::chrono::milliseconds& duration) : ms{duration} {}
  10. // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
  11. Timeout(const std::int32_t& milliseconds) : Timeout{std::chrono::milliseconds(milliseconds)} {}
  12. // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
  13. Timeout(const std::chrono::seconds& duration) : ms{1000 * duration.count()} {}
  14. // No way around since curl uses a long here.
  15. // NOLINTNEXTLINE(google-runtime-int)
  16. long Milliseconds() const;
  17. std::chrono::milliseconds ms;
  18. };
  19. } // namespace cpr
  20. #endif