Skip to content

Commit

Permalink
new ()
Browse files Browse the repository at this point in the history
  • Loading branch information
damianh committed Jun 13, 2024
1 parent 8c568e4 commit 6fade23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/LittleForker/ProcessSupervisor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ public class ProcessSupervisor : IDisposable
private readonly string _processPath;
private readonly StateMachine<State, Trigger>.TriggerWithParameters<Exception> _startErrorTrigger;
private readonly StateMachine<State, Trigger>.TriggerWithParameters<TimeSpan?> _stopTrigger;
private readonly StateMachine<State, Trigger> _processStateMachine
= new StateMachine<State, Trigger>(State.NotStarted, FiringMode.Immediate);
private readonly StateMachine<State, Trigger> _processStateMachine = new(State.NotStarted, FiringMode.Immediate);
private readonly string _workingDirectory;
private Process _process;
private readonly ILoggerFactory _loggerFactory;
private bool _killed;
private readonly TaskQueue _taskQueue = new TaskQueue();
private readonly TaskQueue _taskQueue = new();

/// <summary>
/// The state a process is in.
Expand Down
11 changes: 5 additions & 6 deletions src/LittleForker/TaskQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ namespace LittleForker;
/// </summary>
internal class TaskQueue : IDisposable
{
private readonly ConcurrentQueue<Func<Task>> _taskQueue = new ConcurrentQueue<Func<Task>>();
private readonly CancellationTokenSource _isDisposed = new CancellationTokenSource();
private readonly InterlockedBoolean _isProcessing = new InterlockedBoolean();

private readonly ConcurrentQueue<Func<Task>> _taskQueue = new();
private readonly CancellationTokenSource _isDisposed = new();
private readonly InterlockedBoolean _isProcessing = new();

/// <summary>
/// Enqueues a task for processing.
Expand Down Expand Up @@ -49,7 +48,7 @@ public Task<T> Enqueue<T>(Func<T> function)
/// <summary>
/// Enqueues a task for processing.
/// </summary>
/// <param name="function">The operation to invoke that is co-operatively cancelable.</param>
/// <param name="function">The operation to invoke that is cooperatively cancelable.</param>
/// <returns>A task representing the operation. Awaiting is optional.</returns>
public Task Enqueue(Func<CancellationToken, Task> function)
{
Expand All @@ -64,7 +63,7 @@ public Task Enqueue(Func<CancellationToken, Task> function)
/// <summary>
/// Enqueues a task for processing.
/// </summary>
/// <param name="function">The operation to invoke that is co-operatively cancelable.</param>
/// <param name="function">The operation to invoke that is cooperatively cancelable.</param>
/// <returns>A task representing the operation. Awaiting is optional.</returns>
public Task<TResult> Enqueue<TResult>(Func<CancellationToken, Task<TResult>> function)
{
Expand Down

0 comments on commit 6fade23

Please sign in to comment.