Files
firesse/keepalive.h

31 lines
540 B
C
Raw Permalink Normal View History

#pragma once
#include <atomic>
#include <thread>
#include "index.h"
namespace firesse {
class KeepAlive {
2019-05-18 12:18:26 -07:00
public:
KeepAlive(const std::chrono::nanoseconds& max_stale, Index* index);
~KeepAlive();
2019-05-12 13:49:23 -07:00
2019-05-18 12:18:26 -07:00
void Start();
void Stop();
2019-05-18 12:18:26 -07:00
private:
const std::chrono::nanoseconds max_stale_;
Index* index_;
2019-05-18 12:18:26 -07:00
// 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;
2019-05-18 12:18:26 -07:00
std::thread thread_;
};
2019-05-18 12:18:26 -07:00
} // namespace firesse