using System;
using System.Threading;
namespace OSS.Tools.DataFlow
{
///
/// 数据流选项
///
public class DataFlowOption: DataPublisherOption
{
///
/// 默认选项
///
public static DataFlowOption Default { get; } = new DataFlowOption();
/// 默认最大并发数
private int _maxDegreeOfParallelism = 1;
///
/// 最大并发数
/// 默认:1
///
public int MaxDegreeOfParallelism
{
get => _maxDegreeOfParallelism;
set
{
if (value < 1 && value != Unbounded) throw new ArgumentOutOfRangeException(nameof(value));
_maxDegreeOfParallelism = value;
}
}
///
/// 无限制的值
///
public const int Unbounded = -1;
///
/// 取消通知
///
public CancellationToken CancellationToken { get; set; } = CancellationToken.None;
private int _boundedCapacity = Unbounded;
///
/// 边界容量
/// 默认-1,无限制
///
public int BoundedCapacity
{
get => _boundedCapacity;
set
{
if (value < 1 && value != Unbounded) throw new ArgumentOutOfRangeException(nameof(value));
_boundedCapacity = value;
}
}
}
///
/// 数据发布者选项
///
public class DataPublisherOption
{
///
/// 系统调用来源
///
public string SourceName { get; set; } = "default";
}
}