fortuna/seed_file_management.h

49 lines
1.0 KiB
C
Raw Normal View History

#ifndef FORTUNA_SEED_FILE_MANAGER_H
#define FORTUNA_SEED_FILE_MANAGER_H
#include "accumulator.h"
#include "do_task.h"
#include <chrono>
#include <string>
namespace fortuna {
class SeedFileManager {
public:
2022-01-10 04:25:03 +01:00
struct conf {
// std::chrono::minutes write_interval{10};
// 10 minutes (as the standard recommends) is a lot, go with 120s
std::chrono::seconds write_interval{120};
std::string seed_f_path{"./.fortuna.seed"};
std::size_t seed_f_length{64};
conf(){};
};
static auto is_job_running() -> bool;
auto do_stuff() -> void;
2022-01-13 06:08:40 +01:00
explicit SeedFileManager(
2022-01-10 04:25:03 +01:00
const fortuna::accumulator::Accumulator& accumulator) noexcept;
~SeedFileManager() noexcept;
protected:
static auto set_job_running(bool) -> void;
2021-12-29 04:51:40 +01:00
private:
const conf config;
static constinit bool RUNNING;
DoTask do_task;
2021-12-29 04:51:40 +01:00
fortuna::accumulator::Accumulator accumulator;
auto seed_file_exists() const -> bool;
auto write_seed_file() -> void;
auto update_seed_file() -> void;
}; // class SeedFileManager
} // namespace fortuna
#endif // FORTUNA_SEED_FILE_MANAGER_H