job scheduler works with run once and run periodic schedules. Stop logic is not fully thought through.

Dependencies:   LinkedList

Dependents:   JobSchedulerDemo Borsch

Revision:
8:4ead1f4ab741
Parent:
2:9bf5366ad5a2
Child:
16:f61b62b119dd
--- a/schedules.h	Tue Jul 11 23:03:23 2017 +0000
+++ b/schedules.h	Tue Jul 11 23:12:54 2017 +0000
@@ -20,4 +20,30 @@
             time_t _time;
     };
     
-}
\ No newline at end of file
+    class RunPeriodicSchedule: public ISchedule {
+        public:
+            RunPeriodicSchedule(time_t period, int limit = 0)
+            : _period(period), _limit(limit), _counter(0) {};
+            
+            virtual ~RunPeriodicSchedule() {};
+            
+            virtual time_t NextRunTime(time_t from) {
+                if (_limit > 0 && _counter == _limit) {
+                    // no next run
+                    return 0;
+                }
+                _counter++;
+                time_t next = from + _period;
+                return next;
+            };
+        
+        private:
+            time_t _period;
+            /** limit limits number of times to execute NextRunTime.
+            If set to zero, then it is unlimitted.
+            */
+            int _limit;
+            int _counter;
+    };
+
+} // end of namespace
\ No newline at end of file