Tigher loop in KeepAlive; skip syscalls if overloaded

This commit is contained in:
flamingcow
2019-05-12 16:18:07 -07:00
parent 6efb19f255
commit 07c5e5661d
3 changed files with 14 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include <atomic>
#include <thread>
#include "index.h"
@@ -17,7 +18,11 @@ class KeepAlive {
private:
const std::chrono::nanoseconds max_stale_;
Index* index_;
int shutdown_;
// Two shutdown mechanisms, one for if we're in a tight no-syscall loop,
// and one for if we're sleeping in poll()
int shutdown_fd_;
std::atomic<bool> running_ = true;
std::thread thread_;
};