Scheduler: Hack suppoer for ordinary files into the scheduler (epoll does *not* suppo...
[senf.git] / Scheduler / Daemon.ih
index 23af6ce..5988bca 100644 (file)
@@ -28,6 +28,7 @@
 
 // Custom includes
 #include <deque>
+#include <list>
 #include <boost/utility.hpp>
 #include <boost/function.hpp>
 #include "../Scheduler/Scheduler.hh"
@@ -43,7 +44,7 @@ namespace detail {
     {
     public:
 
-        DaemonWatcher(int pid, int coutpipe, int cerrpipe);
+        DaemonWatcher(int pid, int coutpipe, int cerrpipe, int stdout, int stderr);
 
         void run();
 
@@ -54,33 +55,46 @@ namespace detail {
         public:
             typedef boost::function<void ()> Callback;
 
-            Forwarder(int src, int dst, Callback cb);
+            Forwarder(int src, Callback cb);
             ~Forwarder();
 
+            void addTarget(int fd);
+
         private:
 
+            typedef std::deque<char> Buffer;
+            struct Target
+            {
+                int fd;
+                Buffer::size_type offset;
+            };
+            typedef std::list<Target> Targets;
+
             void readData(Scheduler::EventId event);
-            void writeData(Scheduler::EventId event);
+            void writeData(Scheduler::EventId event, Targets::iterator target);
 
-            typedef std::deque<char> Buffer;
             Buffer buffer_;
             int src_;
-            int dst_;
+
+            Targets targets_;
+
             Callback cb_;
         };
         
-        void pipeClosed();
+        void pipeClosed(int id);
+        void sigChld();
         void childDied();
         void childOk();
 
         int childPid_;
         int coutpipe_;
         int cerrpipe_;
+        int stdout_;
+        int stderr_;
+        bool sigChld_;
 
         Forwarder coutForwarder_;
         Forwarder cerrForwarder_;
-
-        bool timerRunning_;
     };
 
 }}