aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-07-11 13:13:19 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-07-11 13:13:19 +0200
commit4205234f26211baa787fd18de0256622759fea8a (patch)
tree17c17d92dde257a0cf00a919d6ccf24e36287658 /src/libutil
parentb0c220c02ec584af282b9c7f493e4a4d2e429f8c (diff)
parent53247d6b116905e7233b1efd6c14845e20d27442 (diff)
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/retry.hh38
-rw-r--r--src/libutil/types.hh2
2 files changed, 0 insertions, 40 deletions
diff --git a/src/libutil/retry.hh b/src/libutil/retry.hh
deleted file mode 100644
index b45cb37f7..000000000
--- a/src/libutil/retry.hh
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-
-#include "logging.hh"
-
-#include <functional>
-#include <cmath>
-#include <random>
-#include <thread>
-
-namespace nix {
-
-inline unsigned int retrySleepTime(unsigned int attempt)
-{
- std::random_device rd;
- std::mt19937 mt19937;
- return 250.0 * std::pow(2.0f,
- attempt - 1 + std::uniform_real_distribution<>(0.0, 0.5)(mt19937));
-}
-
-template<typename C>
-C retry(unsigned int attempts, std::function<C()> && f)
-{
- unsigned int attempt = 0;
- while (true) {
- try {
- return f();
- } catch (BaseError & e) {
- ++attempt;
- if (attempt >= attempts || !e.isTransient())
- throw;
- auto ms = retrySleepTime(attempt);
- warn("%s; retrying in %d ms", e.what(), ms);
- std::this_thread::sleep_for(std::chrono::milliseconds(ms));
- }
- }
-}
-
-}
diff --git a/src/libutil/types.hh b/src/libutil/types.hh
index 88e3243f4..92bf469b5 100644
--- a/src/libutil/types.hh
+++ b/src/libutil/types.hh
@@ -109,8 +109,6 @@ public:
const string & msg() const { return err; }
const string & prefix() const { return prefix_; }
BaseError & addPrefix(const FormatOrString & fs);
-
- virtual bool isTransient() { return false; }
};
#define MakeError(newClass, superClass) \