aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-04-28 02:21:46 +0200
committereldritch horrors <pennae@lix.systems>2024-05-10 02:21:11 +0200
commitceccac835c55e3b5c805851bad871360641ff1d9 (patch)
tree55cc9d81430e6e8173e3cc4c308d173c6ce69034
parentb66451ae7fe12500f135137155c2aae6c406b2da (diff)
libutil: remove callback.hh
it's no longer used. it really shouldn't have existed this long since it was just a mashup of both std::promise and std::packaged_task in a shape that makes composition unnecessarily difficult. all but a single case of Callback pattern calls were fully synchronous anyway, and even this sole outlier was by far not important enough to justify the extra complexity. Change-Id: I208aec4572bf2501cdbd0f331f27d505fca3a62f
-rw-r--r--src/libstore/binary-cache-store.cc1
-rw-r--r--src/libstore/build/derivation-goal.cc1
-rw-r--r--src/libstore/build/drv-output-substitution-goal.cc1
-rw-r--r--src/libstore/build/local-derivation-goal.cc1
-rw-r--r--src/libstore/dummy-store.cc1
-rw-r--r--src/libstore/filetransfer.cc1
-rw-r--r--src/libstore/http-binary-cache-store.cc1
-rw-r--r--src/libstore/legacy-ssh-store.cc1
-rw-r--r--src/libstore/local-store.cc1
-rw-r--r--src/libstore/misc.cc1
-rw-r--r--src/libstore/remote-store.cc1
-rw-r--r--src/libstore/store-api.cc1
-rw-r--r--src/libutil/callback.hh49
-rw-r--r--src/libutil/meson.build1
-rw-r--r--src/libutil/util.hh4
15 files changed, 0 insertions, 66 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index 85ca36667..e9413cf99 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -11,7 +11,6 @@
#include "nar-accessor.hh"
#include "thread-pool.hh"
#include "signals.hh"
-#include "callback.hh"
#include <chrono>
#include <future>
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index faebd3c43..3f24da276 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -11,7 +11,6 @@
#include "common-protocol.hh"
#include "common-protocol-impl.hh"
#include "topo-sort.hh"
-#include "callback.hh"
#include "local-store.hh" // TODO remove, along with remaining downcasts
#include "logging-json.hh"
diff --git a/src/libstore/build/drv-output-substitution-goal.cc b/src/libstore/build/drv-output-substitution-goal.cc
index 17c96a9c7..735a07f96 100644
--- a/src/libstore/build/drv-output-substitution-goal.cc
+++ b/src/libstore/build/drv-output-substitution-goal.cc
@@ -2,7 +2,6 @@
#include "finally.hh"
#include "worker.hh"
#include "substitution-goal.hh"
-#include "callback.hh"
#include "signals.hh"
namespace nix {
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc
index 5b365accd..e7a1e0147 100644
--- a/src/libstore/build/local-derivation-goal.cc
+++ b/src/libstore/build/local-derivation-goal.cc
@@ -11,7 +11,6 @@
#include "compression.hh"
#include "daemon.hh"
#include "topo-sort.hh"
-#include "callback.hh"
#include "json-utils.hh"
#include "cgroup.hh"
#include "personality.hh"
diff --git a/src/libstore/dummy-store.cc b/src/libstore/dummy-store.cc
index ae2b91370..e97425c80 100644
--- a/src/libstore/dummy-store.cc
+++ b/src/libstore/dummy-store.cc
@@ -1,5 +1,4 @@
#include "store-api.hh"
-#include "callback.hh"
namespace nix {
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index fd0a42cb3..8d508facb 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -6,7 +6,6 @@
#include "signals.hh"
#include "compression.hh"
#include "finally.hh"
-#include "callback.hh"
#if ENABLE_S3
#include <aws/core/client/ClientConfiguration.h>
diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc
index 764f97fc1..9fafabe65 100644
--- a/src/libstore/http-binary-cache-store.cc
+++ b/src/libstore/http-binary-cache-store.cc
@@ -2,7 +2,6 @@
#include "filetransfer.hh"
#include "globals.hh"
#include "nar-info-disk-cache.hh"
-#include "callback.hh"
namespace nix {
diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc
index 23ccfb178..584254afe 100644
--- a/src/libstore/legacy-ssh-store.cc
+++ b/src/libstore/legacy-ssh-store.cc
@@ -9,7 +9,6 @@
#include "path-with-outputs.hh"
#include "ssh.hh"
#include "derivations.hh"
-#include "callback.hh"
namespace nix {
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index a27e43989..7bcbe3298 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -6,7 +6,6 @@
#include "derivations.hh"
#include "nar-info.hh"
#include "references.hh"
-#include "callback.hh"
#include "topo-sort.hh"
#include "signals.hh"
#include "finally.hh"
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index 22f6b67ee..a63a28482 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -5,7 +5,6 @@
#include "store-api.hh"
#include "thread-pool.hh"
#include "topo-sort.hh"
-#include "callback.hh"
#include "closure.hh"
#include "filetransfer.hh"
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 1d3fa93c1..1cdfdb925 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -15,7 +15,6 @@
#include "pool.hh"
#include "finally.hh"
#include "logging.hh"
-#include "callback.hh"
#include "filetransfer.hh"
#include <nlohmann/json.hpp>
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 942e3f521..509b0fa68 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -9,7 +9,6 @@
#include "url.hh"
#include "references.hh"
#include "archive.hh"
-#include "callback.hh"
#include "remote-store.hh"
#include "signals.hh"
// FIXME this should not be here, see TODO below on
diff --git a/src/libutil/callback.hh b/src/libutil/callback.hh
deleted file mode 100644
index 3710d1239..000000000
--- a/src/libutil/callback.hh
+++ /dev/null
@@ -1,49 +0,0 @@
-#pragma once
-///@file
-
-#include <future>
-#include <functional>
-
-namespace nix {
-
-/**
- * A callback is a wrapper around a lambda that accepts a valid of
- * type T or an exception. (We abuse std::future<T> to pass the value or
- * exception.)
- */
-template<typename T>
-class Callback
-{
- std::function<void(std::future<T>)> fun;
- std::atomic_flag done = ATOMIC_FLAG_INIT;
-
-public:
-
- Callback(std::function<void(std::future<T>)> fun) : fun(fun) { }
-
- Callback(Callback && callback) : fun(std::move(callback.fun))
- {
- auto prev = callback.done.test_and_set();
- if (prev) done.test_and_set();
- }
-
- void operator()(T && t) noexcept
- {
- auto prev = done.test_and_set();
- assert(!prev);
- std::promise<T> promise;
- promise.set_value(std::move(t));
- fun(promise.get_future());
- }
-
- void rethrow(const std::exception_ptr & exc = std::current_exception()) noexcept
- {
- auto prev = done.test_and_set();
- assert(!prev);
- std::promise<T> promise;
- promise.set_exception(exc);
- fun(promise.get_future());
- }
-};
-
-}
diff --git a/src/libutil/meson.build b/src/libutil/meson.build
index 8caa0532a..13266f6bd 100644
--- a/src/libutil/meson.build
+++ b/src/libutil/meson.build
@@ -43,7 +43,6 @@ libutil_headers = files(
'args/root.hh',
'args.hh',
'box_ptr.hh',
- 'callback.hh',
'canon-path.hh',
'cgroup.hh',
'chunked-vector.hh',
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index ac4aa1d3a..5adabae28 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -836,10 +836,6 @@ std::optional<typename T::value_type> pop(T & c)
}
-template<typename T>
-class Callback;
-
-
/**
* A RAII helper that increments a counter on construction and
* decrements it on destruction.