Simple task manager which uses a Ticker
Diff: Task.h
- Revision:
- 2:3cb7f5770feb
- Parent:
- 1:e95b703c6ad7
--- a/Task.h Fri Jan 14 20:04:13 2011 +0000 +++ b/Task.h Fri Jan 14 20:24:54 2011 +0000 @@ -5,24 +5,52 @@ #define DEFAULT_INTERVAL 1000 //1ms - +/** + * Override this class to create a Task that can be managed with the TaskManager. + */ class Task { public: + /** + * Contructor. Sets interval to default of 1ms. + */ Task(); + + /** + * Constructor. + * @param _interval The running interval of the task in us. + */ Task(int _interval); + /** + * Starts the task. Should be automatically called from the TaskManager when it is added. + */ void start(); + + /** + * Virtual method which gets called at the specified interval. + */ virtual void tick() = 0; + + /** + * Stops the task from running + */ void stop(); + /** + * Returns true if the task is running. + */ bool isRunning() { return running; } protected: + /** + * Set the interval that the task tick method runs. + * @_interval Interval in us. + */ void setInterval(int _interval) { interval = _interval; }