Exemple #1
0
 public bool run_one()
 {
     Monitor.Enter(_opQueue);
     if (_runSign && 0 != _opQueue.Count)
     {
         MsgQueueNode <Action> firstNode = _opQueue.First;
         _opQueue.RemoveFirst();
         Monitor.Exit(_opQueue);
         functional.catch_invoke(firstNode.Value);
         return(true);
     }
     Monitor.Exit(_opQueue);
     return(false);
 }
Exemple #2
0
        protected bool running_a_round(curr_strand currStrand)
        {
            currStrand.strand = this;
            while (0 != _readyQueue.Count)
            {
                if (0 != _pauseState && 0 != Interlocked.CompareExchange(ref _pauseState, 2, 1))
                {
                    currStrand.strand = null;
                    return(false);
                }
                Action stepHandler = _readyQueue.First.Value;
                _readyQueue.RemoveFirst();
                functional.catch_invoke(stepHandler);
            }
            MsgQueue <Action> waitQueue = _waitQueue;

            Monitor.Enter(this);
            if (0 != _waitQueue.Count)
            {
                _waitQueue = _readyQueue;
                Monitor.Exit(this);
                _readyQueue       = waitQueue;
                currStrand.strand = null;
                next_a_round();
            }
            else
            {
                _locked = false;
                Monitor.Exit(this);
                currStrand.strand = null;
            }
            return(true);
        }