Simple task manager which uses a Ticker
Revision 2:3cb7f5770feb, committed 2011-01-14
- Comitter:
- Phlaphead
- Date:
- Fri Jan 14 20:24:54 2011 +0000
- Parent:
- 1:e95b703c6ad7
- Commit message:
- Added documentation
Changed in this revision
Task.h | Show annotated file Show diff for this revision Revisions of this file |
TaskManager.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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; }
--- a/TaskManager.h Fri Jan 14 20:04:13 2011 +0000 +++ b/TaskManager.h Fri Jan 14 20:24:54 2011 +0000 @@ -8,13 +8,23 @@ using namespace std; - +/** + * TaskManager class manages a list of running or suspended tasks. + */ class TaskManager { public: + /** + * Contructor. + */ TaskManager(); + + /** + * Start a task. + * @param _task The task object to start + */ void startTask(Task* _task); private: