public void ReplaceWith(ThreadSet other) { for (int i = 0; i < _elems.Length; ++i) { _elems[i] = other._elems[i]; } NumElems = other.NumElems; }
public void UnionWith(ThreadSet other) { NumElems = 0; for (int i = 0; i < _elems.Length; ++i) { _elems[i] |= other._elems[i]; if (_elems[i]) { ++NumElems; } } }
public Choice(ThreadSet alternatives) { _alternatives = alternatives; int n = alternatives.NumElems; if (n == 0) { throw new ArgumentOutOfRangeException($"No alternatives to choose between."); } Chosen = _alternatives.Successor(0); _numElemsSeen = 1; }
public void IntersectWith(ThreadSet other) { NumElems = 0; for (int i = 0; i < _elems.Length; ++i) { _elems[i] &= other._elems[i]; if (_elems[i]) { ++NumElems; } } return; }
public int GetNextThreadId(PriorityRelation priority, ThreadSet enabled) { Choice result; if (ResumeInProgress) { result = _choices[_choiceIdx]; _choiceIdx++; } else { var schedulable = priority.GetSchedulableThreads(enabled); result = new Choice(schedulable); _choices[_choiceIdx] = result; _lastChoiceIdx++; _choiceIdx++; } return(result.Chosen); }