aboutsummaryrefslogtreecommitdiff
path: root/src/minicron.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-03-04 15:52:13 +0000
committerMike Buland <eichlan@xagasoft.com>2011-03-04 15:52:13 +0000
commit53202e5711f32c80ec89d149da7de72b2a1fc953 (patch)
treec7a8f688f718ae2643007e85ed1b035658461fd0 /src/minicron.cpp
parent2cb55a3b17d2381c6ec61aea3cea077253ffab3c (diff)
downloadlibbu++-53202e5711f32c80ec89d149da7de72b2a1fc953.tar.gz
libbu++-53202e5711f32c80ec89d149da7de72b2a1fc953.tar.bz2
libbu++-53202e5711f32c80ec89d149da7de72b2a1fc953.tar.xz
libbu++-53202e5711f32c80ec89d149da7de72b2a1fc953.zip
Added some extra functions to Bu::MiniCron to let you execute jobs that are in
the queue immediately, with or without rescheduling, by id or name.
Diffstat (limited to '')
-rw-r--r--src/minicron.cpp57
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
122void 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
148void 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
122Bu::MiniCron::JobInfoList Bu::MiniCron::getJobInfo() 174Bu::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
151void Bu::MiniCron::Job::run() 203void 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