libutil: remove unused functions

Change-Id: I2b1c42460de50aff1f742856654c59fc4ce88e04
This commit is contained in:
eldritch horrors
2026-02-07 20:23:33 +00:00
parent 2cc49da1ec
commit 6063ffead9
5 changed files with 0 additions and 139 deletions
-8
View File
@@ -65,14 +65,6 @@ std::string readLine(int fd)
}
}
void writeLine(int fd, std::string s)
{
s += '\n';
writeFull(fd, s);
}
void readFull(int fd, char * buf, size_t count)
{
while (count) {
-5
View File
@@ -20,11 +20,6 @@ rlimit getOpenFilesLimit();
*/
std::string readLine(int fd);
/**
* Write a line to a file descriptor.
*/
void writeLine(int fd, std::string s);
/**
* Read the contents of a file into a string.
*/
-19
View File
@@ -155,25 +155,6 @@ void triggerInterrupt()
static sigset_t savedSignalMask;
static bool savedSignalMaskIsSet = false;
void setChildSignalMask(sigset_t * sigs)
{
assert(sigs); // C style function, but think of sigs as a reference
#if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
sigemptyset(&savedSignalMask);
// There's no "assign" or "copy" function, so we rely on (math) idempotence
// of the or operator: a or a = a.
sigorset(&savedSignalMask, sigs, sigs);
#else
// Without sigorset, our best bet is to assume that sigset_t is a type that
// can be assigned directly, such as is the case for a sigset_t defined as
// an integer type.
savedSignalMask = *sigs;
#endif
savedSignalMaskIsSet = true;
}
void saveSignalMask() {
if (sigprocmask(SIG_BLOCK, nullptr, &savedSignalMask))
throw SysError("querying signal mask");
-7
View File
@@ -97,13 +97,6 @@ void startSignalHandlerThread();
*/
void saveSignalMask();
/**
* Sets the signal mask. Like saveSignalMask() but for a signal set that doesn't
* necessarily match the current thread's mask.
* See saveSignalMask() to set the saved mask to the current mask.
*/
void setChildSignalMask(sigset_t *sigs);
struct InterruptCallback
{
virtual ~InterruptCallback() { };
-100
View File
@@ -91,106 +91,6 @@ private:
void shutdown();
};
/**
* Process in parallel a set of items of type T that have a partial
* ordering between them. Thus, any item is only processed after all
* its dependencies have been processed.
*/
template<typename T>
void processGraph(
const char *poolName,
const std::set<T> & nodes,
std::function<std::set<T>(AsyncIoRoot &, const T &)> getEdges,
std::function<void(AsyncIoRoot &, const T &)> processNode)
{
struct Graph {
std::set<T> left;
std::map<T, std::set<T>> refs, rrefs;
};
Sync<Graph> graph_(Graph{nodes, {}, {}});
std::function<void(AsyncIoRoot &, const T &)> worker;
/* Create pool last to ensure threads are stopped before other destructors
* run */
ThreadPool pool{poolName};
worker = [&](AsyncIoRoot & aio, const T & node) {
{
auto graph(graph_.lock());
auto i = graph->refs.find(node);
if (i == graph->refs.end())
goto getRefs;
goto doWork;
}
getRefs:
{
auto refs = getEdges(aio, node);
refs.erase(node);
{
auto graph(graph_.lock());
for (auto & ref : refs)
if (graph->left.count(ref)) {
graph->refs[node].insert(ref);
graph->rrefs[ref].insert(node);
}
if (graph->refs[node].empty())
goto doWork;
}
}
return;
doWork:
processNode(aio, node);
/* Enqueue work for all nodes that were waiting on this one
and have no unprocessed dependencies. */
{
auto graph(graph_.lock());
for (auto & rref : graph->rrefs[node]) {
auto & refs(graph->refs[rref]);
auto i = refs.find(node);
assert(i != refs.end());
refs.erase(i);
if (refs.empty())
pool.enqueueWithAio(std::bind(worker, std::placeholders::_1, rref));
}
graph->left.erase(node);
graph->refs.erase(node);
graph->rrefs.erase(node);
}
};
for (auto & node : nodes)
pool.enqueueWithAio(std::bind(worker, std::placeholders::_1, std::ref(node)));
pool.process();
if (!graph_.lock()->left.empty())
throw Error("graph processing incomplete (cyclic reference?)");
}
template<typename T>
void processGraph(
const char *poolName,
const std::set<T> & nodes,
std::function<std::set<T>(const T &)> getEdges,
std::function<void(const T &)> processNode)
{
processGraph<T>(
poolName,
nodes,
[&](AsyncIoRoot &, const T & node) { return getEdges(node); },
[&](AsyncIoRoot &, const T & node) { processNode(node); }
);
}
template<typename T>
kj::Promise<Result<void>> processGraphAsync(
const std::set<T> & nodes,