// Spectre 2 // // Douglas Thrift // // $Id$ #ifndef _Daemon_hpp_ #define _Daemon_hpp_ #include "Spectre2.hpp" #ifndef MENES_PRAGMA_ONCE #pragma once #endif #include #include #include class Share; class Daemon { private: const api::Path& config; bool running, loaded; unsigned interval; _H thread; int loop(); void load(); template int work(); template int work_(const Share& share); void sleep(); public: Daemon(const api::Path& config) : config(config), running(true), loaded(false), interval(60), thread(new api::Thread(etl::BindAll(&Daemon::loop, this))) {} ~Daemon(); static ext::RedBlackSet shares; #ifdef __FreeBSD__ static ext::String secret; static api::ThreadMutex secretLock; #else static ext::RedBlackMap secrets; static api::ThreadMutex secretsLock; #endif void reload() { loaded = false; } void stop() { running = false; } }; #endif//_Daemon_hpp_