Fix wrong casts/Selects
This commit is contained in:
parent
e29a142935
commit
b7a4c263e7
@ -5,18 +5,7 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="a5539feb-580a-4d73-b339-a1169a4234ae" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.idea.JobQueue/.idea/.gitignore" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.idea.JobQueue/.idea/encodings.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.idea.JobQueue/.idea/indexLayout.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.idea.JobQueue/.idea/vcs.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/.idea.TaskQueue/.idea/workspace.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/JobQueue.sln" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/JobQueue/Job.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/JobQueue/JobQueue.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/JobQueue/JobQueue.csproj" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/JobQueue/ProgressState.cs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/JobQueue/ProgressToken.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.TaskQueue/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.TaskQueue/.idea/workspace.xml" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -70,16 +59,47 @@
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1708636916152</updated>
|
||||
<workItem from="1708636917346" duration="3150000" />
|
||||
<workItem from="1708636917346" duration="4692000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Initial Commit">
|
||||
<option name="closed" value="true" />
|
||||
<created>1708641452330</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1708641452330</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00002" summary="Files">
|
||||
<option name="closed" value="true" />
|
||||
<created>1708641518087</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1708641518087</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="3" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="UnityCheckinConfiguration" checkUnsavedScenes="true" />
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||
<MESSAGE value="Initial Commit" />
|
||||
<MESSAGE value="Files" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Files" />
|
||||
</component>
|
||||
</project>
|
@ -43,7 +43,7 @@ public abstract class Job : IComparable
|
||||
this.LastStarted = DateTime.UtcNow;
|
||||
this.ProgressToken.Start();
|
||||
this._logger?.LogDebug($"Started Job {JobId}");
|
||||
this.Execute(ProgressToken._cancellationTokenSource.Token);
|
||||
this.Execute(ProgressToken.CancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
@ -54,7 +54,7 @@ public abstract class Job : IComparable
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.ProgressToken._cancellationTokenSource.Cancel();
|
||||
this.ProgressToken.CancellationTokenSource.Cancel();
|
||||
this.ProgressToken = ProgressToken.Clone();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ namespace JobQueue;
|
||||
public class JobQueue<T> : IDisposable where T : notnull
|
||||
{
|
||||
private readonly Dictionary<T, HashSet<Job>> _queues = new();
|
||||
public Dictionary<T, HashSet<Job>> FailedJobs { get; init; } = new();
|
||||
private Dictionary<T, HashSet<Job>> FailedJobs { get; init; } = new();
|
||||
private bool _running = true;
|
||||
private readonly ILogger? _logger;
|
||||
|
||||
@ -26,8 +26,8 @@ public class JobQueue<T> : IDisposable where T : notnull
|
||||
startJob?.Start();
|
||||
}
|
||||
|
||||
foreach (Job job in _queues.Values.Select(queue =>
|
||||
queue.Select(job => job.ProgressToken.State is ProgressState.Finished or ProgressState.Cancelled)))
|
||||
foreach (Job job in _queues.Values.SelectMany(job => job).Where(job =>
|
||||
job.ProgressToken.State is ProgressState.Finished or ProgressState.Cancelled))
|
||||
{
|
||||
this._logger?.LogInformation($"Job finished: {job}");
|
||||
job.Reset();
|
||||
@ -99,7 +99,7 @@ public class JobQueue<T> : IDisposable where T : notnull
|
||||
{
|
||||
this._logger?.LogInformation("Shutting down JobQueue.");
|
||||
_running = false;
|
||||
foreach(Job job in _queues.Values.Select(set => set.Select(_ => true)))
|
||||
foreach(Job job in _queues.Values.SelectMany(list => list))
|
||||
job.Cancel();
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ public struct ProgressToken
|
||||
public float Progress { get; private set; }
|
||||
public int? Steps { get; init; }
|
||||
public int? FinishedSteps { get; private set; }
|
||||
internal CancellationTokenSource _cancellationTokenSource { get; } = new();
|
||||
internal CancellationTokenSource CancellationTokenSource { get; } = new();
|
||||
private readonly ILogger? _logger;
|
||||
|
||||
public ProgressToken(int? steps = null, ILogger? logger = null)
|
||||
@ -47,13 +47,13 @@ public struct ProgressToken
|
||||
public void Start() => ChangeState(ProgressState.Running);
|
||||
public void Cancel()
|
||||
{
|
||||
_cancellationTokenSource.Cancel();
|
||||
CancellationTokenSource.Cancel();
|
||||
ChangeState(ProgressState.Cancelled);
|
||||
}
|
||||
|
||||
public void MarkFailed()
|
||||
{
|
||||
_cancellationTokenSource.Cancel();
|
||||
CancellationTokenSource.Cancel();
|
||||
ChangeState(ProgressState.Failed);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user