Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Task.h
- Revision:
- 2:3cb7f5770feb
- Parent:
- 1:e95b703c6ad7
diff -r e95b703c6ad7 -r 3cb7f5770feb Task.h
--- 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; }