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