ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Spectre2/Daemon.hpp
(Generate patch)

Comparing Spectre2/Daemon.hpp (file contents):
Revision 428 by douglas, 2005-03-24T17:38:00-08:00 vs.
Revision 441 by douglas, 2005-04-12T15:42:24-07:00

# Line 17 | Line 17
17   #include <menes-etl/fnbind.hpp>
18   #include <menes-ext/threadset.hpp>
19  
20 + class Share;
21 +
22   class Daemon
23   {
24   private:
25 +        const api::Path& config;
26 +        bool running, loaded;
27 +        unsigned interval;
28          _H<api::Thread> thread;
29          int loop();
30 < protected:
31 <        bool running, loaded;
32 <        virtual void load() = 0;
33 <        virtual void run() = 0;
34 <        Daemon() : running(false), loaded(false) {}
30 >        void load();
31 >        template <typename Worker>
32 >                int work();
33 >        template <typename Worker>
34 >                int work_(const Share& share);
35 >        void sleep();
36   public:
37 <        virtual ~Daemon() { if (!thread.IsEmpty()) thread->Join(); }
38 <        void start();
39 <        void wait();
37 >        Daemon(const api::Path& config) : config(config), running(true), loaded(false), interval(60), thread(new api::Thread(etl::BindAll(&Daemon::loop, this))) {}
38 >        ~Daemon();
39 >        static ext::RedBlackSet<Share> shares;
40 > #ifdef __FreeBSD__
41 >        static ext::String secret;
42 >        static api::ThreadMutex secretLock;
43 > #else
44 >        static ext::RedBlackMap<ext::String, ext::String> secrets;
45 >        static api::ThreadMutex secretsLock;
46 > #endif
47          void reload() { loaded = false; }
48          void stop() { running = false; }
49   };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines