Changed (fixed?) queuelogic
This commit is contained in:
parent
306cb87d67
commit
3c2ce266f6
@ -61,12 +61,12 @@ public abstract class Job : GlobalBase
|
||||
{
|
||||
this.progressToken.increments -= progressToken.incrementsCompleted;
|
||||
this.lastExecution = DateTime.Now;
|
||||
this.progressToken.Waiting();
|
||||
}
|
||||
|
||||
public void ExecutionEnqueue()
|
||||
{
|
||||
this.progressToken.increments -= progressToken.incrementsCompleted;
|
||||
this.lastExecution = recurrenceTime is not null ? DateTime.Now.Subtract((TimeSpan)recurrenceTime) : DateTime.UnixEpoch;
|
||||
this.progressToken.Standby();
|
||||
}
|
||||
|
||||
|
@ -220,8 +220,7 @@ public class JobBoss : GlobalBase
|
||||
|
||||
public void CheckJobs()
|
||||
{
|
||||
foreach (Job job in jobs.Where(job => job.nextExecution < DateTime.Now && !QueueContainsJob(job)).OrderBy(job => job.nextExecution))
|
||||
AddJobToQueue(job);
|
||||
AddJobsToQueue(jobs.Where(job => job.progressToken.state == ProgressToken.State.Waiting && job.nextExecution < DateTime.Now && !QueueContainsJob(job)).OrderBy(job => job.nextExecution));
|
||||
foreach (Queue<Job> jobQueue in mangaConnectorJobQueue.Values)
|
||||
{
|
||||
if(jobQueue.Count < 1)
|
||||
@ -229,19 +228,10 @@ public class JobBoss : GlobalBase
|
||||
Job queueHead = jobQueue.Peek();
|
||||
if (queueHead.progressToken.state is ProgressToken.State.Complete or ProgressToken.State.Cancelled)
|
||||
{
|
||||
switch (queueHead)
|
||||
{
|
||||
case DownloadChapter:
|
||||
RemoveJob(queueHead);
|
||||
break;
|
||||
case DownloadNewChapters:
|
||||
if(queueHead.recurring)
|
||||
queueHead.progressToken.Complete();
|
||||
break;
|
||||
}
|
||||
queueHead.ResetProgress();
|
||||
if(!queueHead.recurring)
|
||||
RemoveJob(queueHead);
|
||||
jobQueue.Dequeue();
|
||||
ExportJob(queueHead);
|
||||
Log($"Next job in {jobs.MinBy(job => job.nextExecution)?.nextExecution.Subtract(DateTime.Now)} {jobs.MinBy(job => job.nextExecution)?.id}");
|
||||
}else if (queueHead.progressToken.state is ProgressToken.State.Standby)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ public class ProgressToken
|
||||
public DateTime executionStarted { get; private set; }
|
||||
public TimeSpan timeRemaining => GetTimeRemaining();
|
||||
|
||||
public enum State { Running, Complete, Standby, Cancelled }
|
||||
public enum State { Running, Complete, Standby, Cancelled, Waiting }
|
||||
public State state { get; private set; }
|
||||
|
||||
public ProgressToken(int increments)
|
||||
@ -18,7 +18,7 @@ public class ProgressToken
|
||||
this.cancellationRequested = false;
|
||||
this.increments = increments;
|
||||
this.incrementsCompleted = 0;
|
||||
this.state = State.Complete;
|
||||
this.state = State.Waiting;
|
||||
this.executionStarted = DateTime.UnixEpoch;
|
||||
}
|
||||
|
||||
@ -63,4 +63,9 @@ public class ProgressToken
|
||||
{
|
||||
state = State.Cancelled;
|
||||
}
|
||||
|
||||
public void Waiting()
|
||||
{
|
||||
state = State.Waiting;
|
||||
}
|
||||
}
|
@ -72,11 +72,6 @@ public partial class Tranga : GlobalBase
|
||||
jobBoss.CheckJobs();
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
foreach (MangaConnector connector in _connectors)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
t.Start();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user