/// <summary> /// Creates a new instance of the <see cref="LogicalThread"/> class. /// </summary> /// <param name="scheduler">The <see cref="LogicalThreadScheduler"/> that created this thread.</param> /// <exception cref="ArgumentNullException"><paramref name="scheduler"/> is null.</exception> internal LogicalThread(LogicalThreadScheduler scheduler) { if ((object)scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } m_scheduler = scheduler; m_queues = new ConcurrentQueue <Action> [PriorityLevels]; m_threadLocalStorage = new Dictionary <object, object>(); m_nextExecutionToken = new CancellationToken(); m_statistics = new LogicalThreadStatistics(); for (int i = 0; i < m_queues.Length; i++) { m_queues[i] = new ConcurrentQueue <Action>(); } }
/// <summary> /// Creates a new instance of the <see cref="LogicalThread"/> class. /// </summary> /// <param name="scheduler">The <see cref="LogicalThreadScheduler"/> that created this thread.</param> /// <param name="priorityLevels">The number of levels of priority supported by this logical thread.</param> /// <exception cref="ArgumentNullException"><paramref name="scheduler"/> is null.</exception> /// <exception cref="ArgumentException"><paramref name="priorityLevels"/> is less than or equal to zero.</exception> internal LogicalThread(LogicalThreadScheduler scheduler, int priorityLevels) { if ((object)scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } if (priorityLevels <= 0) { throw new ArgumentException($"A logical thread must have at least one priority level.", nameof(priorityLevels)); } m_scheduler = scheduler; m_queues = new ConcurrentQueue <Action> [priorityLevels]; m_threadLocalStorage = new Dictionary <object, object>(); m_statistics = new LogicalThreadStatistics(); for (int i = 0; i < m_queues.Length; i++) { m_queues[i] = new ConcurrentQueue <Action>(); } }
/// <summary> /// Creates a new instance of the <see cref="LogicalThread"/> class. /// </summary> /// <param name="scheduler">The <see cref="LogicalThreadScheduler"/> that created this thread.</param> /// <param name="priorityLevels">The number of levels of priority supported by this logical thread.</param> /// <exception cref="ArgumentNullException"><paramref name="scheduler"/> is null.</exception> /// <exception cref="ArgumentException"><paramref name="priorityLevels"/> is less than or equal to zero.</exception> internal LogicalThread(LogicalThreadScheduler scheduler, int priorityLevels) { if ((object)scheduler == null) throw new ArgumentNullException(nameof(scheduler)); if (priorityLevels <= 0) throw new ArgumentException($"A logical thread must have at least one priority level.", nameof(priorityLevels)); m_scheduler = scheduler; m_queues = new ConcurrentQueue<Action>[priorityLevels]; m_threadLocalStorage = new Dictionary<object, object>(); m_statistics = new LogicalThreadStatistics(); for (int i = 0; i < m_queues.Length; i++) m_queues[i] = new ConcurrentQueue<Action>(); }