diff options
Diffstat (limited to 'src/minicron.cpp')
-rw-r--r-- | src/minicron.cpp | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/src/minicron.cpp b/src/minicron.cpp index 3375492..95cf66b 100644 --- a/src/minicron.cpp +++ b/src/minicron.cpp | |||
@@ -119,6 +119,58 @@ void Bu::MiniCron::removeJob( JobId jid ) | |||
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | void Bu::MiniCron::runJob( JobId jid, bool bReschedule ) | ||
123 | { | ||
124 | Bu::List<Job *> lJobs; | ||
125 | while( !hJobs.isEmpty() ) | ||
126 | { | ||
127 | Job *pJob = hJobs.dequeue(); | ||
128 | if( pJob->getId() == jid ) | ||
129 | { | ||
130 | pJob->run( bReschedule ); | ||
131 | if( !pJob->bContinue ) | ||
132 | { | ||
133 | delete pJob; | ||
134 | break; | ||
135 | } | ||
136 | lJobs.append( pJob ); | ||
137 | break; | ||
138 | } | ||
139 | lJobs.append( pJob ); | ||
140 | } | ||
141 | |||
142 | for( Bu::List<Job *>::iterator i = lJobs.begin(); i; i++ ) | ||
143 | { | ||
144 | hJobs.enqueue( *i ); | ||
145 | } | ||
146 | } | ||
147 | |||
148 | void Bu::MiniCron::runJob( const Bu::String &sName, bool bReschedule ) | ||
149 | { | ||
150 | Bu::List<Job *> lJobs; | ||
151 | while( !hJobs.isEmpty() ) | ||
152 | { | ||
153 | Job *pJob = hJobs.dequeue(); | ||
154 | if( pJob->getName() == sName ) | ||
155 | { | ||
156 | pJob->run( bReschedule ); | ||
157 | if( !pJob->bContinue ) | ||
158 | { | ||
159 | delete pJob; | ||
160 | break; | ||
161 | } | ||
162 | lJobs.append( pJob ); | ||
163 | break; | ||
164 | } | ||
165 | lJobs.append( pJob ); | ||
166 | } | ||
167 | |||
168 | for( Bu::List<Job *>::iterator i = lJobs.begin(); i; i++ ) | ||
169 | { | ||
170 | hJobs.enqueue( *i ); | ||
171 | } | ||
172 | } | ||
173 | |||
122 | Bu::MiniCron::JobInfoList Bu::MiniCron::getJobInfo() | 174 | Bu::MiniCron::JobInfoList Bu::MiniCron::getJobInfo() |
123 | { | 175 | { |
124 | JobInfoList lRet; | 176 | JobInfoList lRet; |
@@ -148,10 +200,11 @@ Bu::MiniCron::Job::~Job() | |||
148 | pTimer = NULL; | 200 | pTimer = NULL; |
149 | } | 201 | } |
150 | 202 | ||
151 | void Bu::MiniCron::Job::run() | 203 | void Bu::MiniCron::Job::run( bool bReschedule ) |
152 | { | 204 | { |
153 | iRunCount++; | 205 | iRunCount++; |
154 | tNextRun = pTimer->nextTime(); | 206 | if( bReschedule ) |
207 | tNextRun = pTimer->nextTime(); | ||
155 | sigJob( *this ); | 208 | sigJob( *this ); |
156 | } | 209 | } |
157 | 210 | ||