예제 #1
0
 public void ReplaceWith(ThreadSet other)
 {
     for (int i = 0; i < _elems.Length; ++i)
     {
         _elems[i] = other._elems[i];
     }
     NumElems = other.NumElems;
 }
예제 #2
0
 public void UnionWith(ThreadSet other)
 {
     NumElems = 0;
     for (int i = 0; i < _elems.Length; ++i)
     {
         _elems[i] |= other._elems[i];
         if (_elems[i])
         {
             ++NumElems;
         }
     }
 }
예제 #3
0
        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;
        }
예제 #4
0
 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;
 }
예제 #5
0
        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);
        }