Adding two small helpers to scheduler
diff --git a/scheduler/scheduler.h b/scheduler/scheduler.h
index 83b9926..e783cf0 100644
--- a/scheduler/scheduler.h
+++ b/scheduler/scheduler.h
@@ -38,6 +38,10 @@
#include <sys/time.h>
#include "task.h"
+#include "interval-generator.h"
+
+class Scheduler;
+typedef boost::shared_ptr<Scheduler> SchedulerPtr;
/**
* @brief Scheduler class
@@ -56,9 +60,18 @@
virtual void
shutdown();
+ // helper method to schedule one-time task
+ static TaskPtr
+ scheduleOneTimeTask (SchedulerPtr scheduler, double delay, const Task::Callback &callback, const Task::Tag &tag);
+
+ // helper method to schedule periodic task
+ static TaskPtr
+ schedulePeriodicTask (SchedulerPtr scheduler, IntervalGeneratorPtr delayGenerator,
+ const Task::Callback &callback, const Task::Tag &tag);
+
// if task with the same tag exists, the task is not added and return false
virtual bool
- addTask(const TaskPtr &task);
+ addTask(TaskPtr task);
// delete task by task->tag, regardless of whether it's invoked or not
virtual void
@@ -117,9 +130,6 @@
boost::thread m_thread;
};
-class Scheduler;
-typedef boost::shared_ptr<Scheduler> SchedulerPtr;
-
struct SchedulerException : virtual boost::exception, virtual std::exception { };
#endif // SCHEDULER_H