]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Add Job::higherPriority(const Job&) const
authorAidan Van Dyk <aidan@ifax.com>
Fri, 4 May 2007 17:23:10 +0000 (17:23 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Fri, 4 May 2007 17:23:10 +0000 (17:23 +0000)
This allows us to consolidate the knowledge of how a job sorts
based on priority.

faxd/Job.c++
faxd/Job.h
faxd/faxQueueApp.c++

index 93de0f367ccd21fbe17413fb819437e93bae9431..5be3e1ce98decfca77121a0ee49756377eb195f9 100644 (file)
@@ -147,6 +147,16 @@ Job::getJobByID(const fxStr& id)
     return (jpp ? *jpp : (Job*) NULL);
 }
 
+bool
+Job::higherPriority (const Job& other) const
+{
+    if (pri < other.pri)
+       return true;
+    if (pri == other.pri && tts <= other.tts)
+       return true;
+    return false;
+}
+
 void
 Job::startKillTimer(long sec)
 {
index f2246c7065f50049c39d7051029b2c68d2dfa585..139a96f52b3848aaba7f4e2ce1925d8396659cbc 100644 (file)
@@ -157,6 +157,8 @@ public:
     static Job* getJobByID(const fxStr& jobid);
     static fxStr jobStatusName(const JobStatus);
 
+    bool higherPriority(const Job& other) const;
+
     void startKillTimer(long sec);
     void stopKillTimer();
 
index 01439ce1856a279d847a392d7efbf2c932f473f2..cf2a6c838cc52c4cfa5e81de10c96f991a39bff1 100644 (file)
@@ -1615,9 +1615,9 @@ faxQueueApp::setReady(Job& job)
     traceJob(job, "READY");
     Trigger::post(Trigger::JOB_READY, job);
     JobIter iter(runqs[JOBHASH(job.pri)]);
-    for (; iter.notDone() && (iter.job().pri < job.pri || 
-      (iter.job().pri == job.pri && iter.job().tts <= job.tts)); iter++)
-       ;
+    for (; iter.notDone(); iter++)
+       if (! iter.job().higherPriority(job))
+           break;
     job.insert(iter.job());
     /*
      * In order to deliberately batch jobs by using a common