44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
|
namespace ConsoleApp2.Services;
|
|||
|
|
|||
|
public class ProcessContext
|
|||
|
{
|
|||
|
private int _inputCount;
|
|||
|
private int _transformCount;
|
|||
|
private int _outputCount;
|
|||
|
public bool IsInputCompleted { get; private set; }
|
|||
|
public bool IsTransformCompleted { get; private set; }
|
|||
|
public bool IsOutputCompleted { get; private set; }
|
|||
|
|
|||
|
public int InputCount
|
|||
|
{
|
|||
|
get => _inputCount;
|
|||
|
private set => _inputCount = value;
|
|||
|
}
|
|||
|
|
|||
|
public int TransformCount
|
|||
|
{
|
|||
|
get => _transformCount;
|
|||
|
private set => _transformCount = value;
|
|||
|
}
|
|||
|
|
|||
|
public int OutputCount
|
|||
|
{
|
|||
|
get => _outputCount;
|
|||
|
private set => _outputCount = value;
|
|||
|
}
|
|||
|
|
|||
|
public void CompleteInput() => IsInputCompleted = true;
|
|||
|
|
|||
|
public void CompleteTransform() => IsTransformCompleted = true;
|
|||
|
public void CompleteOutput() => IsOutputCompleted = true;
|
|||
|
|
|||
|
public void AddInput() => Interlocked.Increment(ref _inputCount);
|
|||
|
|
|||
|
public void AddInput(int count) => Interlocked.Add(ref _inputCount, count);
|
|||
|
|
|||
|
public void AddTransform() => Interlocked.Increment(ref _transformCount);
|
|||
|
public void AddTransform(int count) => Interlocked.Add(ref _transformCount, count);
|
|||
|
|
|||
|
public void AddOutput() => Interlocked.Increment(ref _outputCount);
|
|||
|
public void AddOutput(int count) => Interlocked.Add(ref _outputCount, count);
|
|||
|
}
|