//- $SortPriority -// private static Int32 SortPriority(IHasPriority p1, IHasPriority p2) { if (p2.Priority > p1.Priority) { return -1; } else if (p1.Priority > p2.Priority) { return 1; } //+ return 0; }
/// <summary> /// Enqueue a work item. /// </summary> /// <param name="workItem">A work item</param> public void Enqueue(IHasPriority workItem) { Debug.Assert(null != workItem); int queueIndex = _queuesCount - (int)workItem.Priority - 1; Debug.Assert(queueIndex >= 0); Debug.Assert(queueIndex < _queuesCount); _queues[queueIndex].AddLast(workItem); ++_workItemsCount; ++_version; }