aboutsummaryrefslogtreecommitdiff
path: root/src/minicron.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/minicron.h51
1 files changed, 44 insertions, 7 deletions
diff --git a/src/minicron.h b/src/minicron.h
index 7475020..b045e79 100644
--- a/src/minicron.h
+++ b/src/minicron.h
@@ -66,6 +66,12 @@ namespace Bu
66 *@returns The timestamp that the next job will execute at. 66 *@returns The timestamp that the next job will execute at.
67 */ 67 */
68 virtual time_t getNextRun(); 68 virtual time_t getNextRun();
69
70 /**
71 * Tells you the time the job matching jid will run next.
72 *@returns The timestamp that the job jid will next run.
73 */
74 virtual time_t getNextRun( JobId jid );
69 75
70 /** 76 /**
71 * Call this regularly to execute all jobs that should be executed. 77 * Call this regularly to execute all jobs that should be executed.
@@ -83,7 +89,8 @@ namespace Bu
83 * JobId which can be used at a later time to control the execution of 89 * JobId which can be used at a later time to control the execution of
84 * the job. 90 * the job.
85 */ 91 */
86 virtual JobId addJob( CronSignal sigJob, const Timer &t ); 92 virtual JobId addJob( const Bu::FString &sName, CronSignal sigJob,
93 const Timer &t );
87 94
88 /** 95 /**
89 * Add a job for one time scheduling. Pass in a slot to signal, and a 96 * Add a job for one time scheduling. Pass in a slot to signal, and a
@@ -91,7 +98,8 @@ namespace Bu
91 * function returns a JobId which can be used at a later time to control 98 * function returns a JobId which can be used at a later time to control
92 * the execution of the job. 99 * the execution of the job.
93 */ 100 */
94 virtual JobId addJobOnce( CronSignal sigJob, const Timer &t ); 101 virtual JobId addJobOnce( const Bu::FString &sName, CronSignal sigJob,
102 const Timer &t );
95 103
96 /** 104 /**
97 * Remove a job, preventing all future runs of the job. If there is no 105 * Remove a job, preventing all future runs of the job. If there is no
@@ -102,6 +110,22 @@ namespace Bu
102 */ 110 */
103 virtual void removeJob( JobId jid ); 111 virtual void removeJob( JobId jid );
104 112
113 class JobInfo
114 {
115 public:
116 JobInfo( const Bu::FString &sName, JobId jid, time_t tNext );
117 virtual ~JobInfo();
118
119 bool operator<( const JobInfo &rhs ) const;
120
121 Bu::FString sName;
122 JobId jid;
123 time_t tNext;
124 };
125 typedef Bu::List<JobInfo> JobInfoList;
126
127 JobInfoList getJobInfo();
128
105 /** 129 /**
106 * The baseclass for timer/schedulers for MiniCron jobs. Classes that 130 * The baseclass for timer/schedulers for MiniCron jobs. Classes that
107 * inherit from this are used to determine when jobs will run and at 131 * inherit from this are used to determine when jobs will run and at
@@ -201,7 +225,7 @@ namespace Bu
201 { 225 {
202 friend class Bu::MiniCron; 226 friend class Bu::MiniCron;
203 private: 227 private:
204 Job( JobId jid, bool bRepeat=true ); 228 Job( const Bu::FString &sName, JobId jid, bool bRepeat=true );
205 virtual ~Job(); 229 virtual ~Job();
206 230
207 public: 231 public:
@@ -215,7 +239,7 @@ namespace Bu
215 /** 239 /**
216 * Get the time this job will next run. 240 * Get the time this job will next run.
217 */ 241 */
218 time_t getNextRun(); 242 time_t getNextRun() const;
219 243
220 /** 244 /**
221 * Compute the time this job will next run. 245 * Compute the time this job will next run.
@@ -243,20 +267,33 @@ namespace Bu
243 /** 267 /**
244 * Get the unique ID of this job. 268 * Get the unique ID of this job.
245 */ 269 */
246 JobId getId(); 270 JobId getId() const;
247 271
248 /** 272 /**
249 * Get the timestamp this job was created. 273 * Get the timestamp this job was created.
250 */ 274 */
251 time_t getTimeCreated(); 275 time_t getTimeCreated() const;
252 276
253 /** 277 /**
254 * Get the current run count of this job, how many times it has been 278 * Get the current run count of this job, how many times it has been
255 * executed. This is incremented before the slot is signaled. 279 * executed. This is incremented before the slot is signaled.
256 */ 280 */
257 int getRunCount(); 281 int getRunCount() const;
282
283 /**
284 * Get the next time that this job will be run. Certain timers may
285 * have the ability to delay job executions, so this is the earliest
286 * time that the job may run.
287 */
288 time_t getNextRunTime() const;
289
290 /**
291 * Gets the name that was set when the job was created.
292 */
293 Bu::FString getName() const;
258 294
259 private: 295 private:
296 Bu::FString sName;
260 CronSignal sigJob; 297 CronSignal sigJob;
261 time_t tNextRun; 298 time_t tNextRun;
262 Timer *pTimer; 299 Timer *pTimer;