]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/arducontrol.h
Improve ArduControl task scheduling
[r2c2.git] / source / libr2c2 / arducontrol.h
index 4373a84f707713e6b7d80c1e927875719b6cad0a..c170e4203c9c2eb3de864de49d958a0a10b6e794 100644 (file)
@@ -226,12 +226,23 @@ private:
        class Task
        {
        protected:
-               Task() { }
+               std::string name;
+               unsigned priority;
+               Msp::Time::TimeStamp sleep_timeout;
+
+               Task(const std::string &, unsigned = 0);
        public:
                virtual ~Task() { }
 
+               const std::string &get_name() const { return name; }
+
                virtual bool get_work(PendingCommand &) = 0;
                virtual void process_reply(const char *, unsigned) { }
+
+               unsigned get_priority() const { return priority; }
+               const Msp::Time::TimeStamp &get_sleep_timeout() const { return sleep_timeout; }
+       protected:
+               void sleep(const Msp::Time::TimeDelta &);
        };
 
        class CommandQueueTask: public Task
@@ -240,6 +251,8 @@ private:
                Queue<PendingCommand> queue;
 
        public:
+               CommandQueueTask();
+
                virtual bool get_work(PendingCommand &);
 
                void push(const PendingCommand &);
@@ -276,7 +289,6 @@ private:
                ArduControl &control;
                unsigned n_octets;
                unsigned octets_remaining;
-               unsigned delay;
 
        public:
                S88Task(ArduControl &);
@@ -292,7 +304,6 @@ private:
        {
        private:
                unsigned serial;
-               Msp::Time::TimeStamp next;
 
        public:
                MfxAnnounceTask();
@@ -308,7 +319,6 @@ private:
        private:
                ArduControl &control;
                unsigned next_address;
-               Msp::Time::TimeStamp next;
                unsigned size;
                unsigned bits;
                unsigned misses;
@@ -331,7 +341,6 @@ private:
                float current;
                float base_level;
                float peak_level;
-               Msp::Time::TimeStamp next_poll;
                unsigned next_type;
 
        public: