Example #1
0
 public override void Lock()
 {
     if (_left != null)
     {
         _left.Lock();
     }
     _right.Lock();
 }
Example #2
0
        public static void DoYield(RCRunner runner, RCClosure closure, RCValue result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            // Check to see if this fiber was killed before moving on
            RCBot bot = runner.GetBot(closure.Bot);

            if (bot.IsFiberDone(closure.Fiber))
            {
                runner.Continue(closure, null);
                return;
            }
            // Do not permit any further changes to result or its children values.
            result.Lock();
            RCClosure next = closure.Code.Next(runner, closure, closure, result);

            if (next == null)
            {
                result = closure.Code.Finish(runner, closure, result);
                bot.ChangeFiberState(closure.Fiber, "done");
                RCSystem.Log.Record(closure, "fiber", closure.Fiber, "done", "");
                if (closure.Fiber == 0 && closure.Bot == 0)
                {
                    runner.Finish(closure, result);
                }
                // This will handle fibers that wake up from some suspended state
                // without realizing that they have been killed.
                else
                {
                    bot.FiberDone(runner, closure.Bot, closure.Fiber, result);
                }
                // Remove closure from the pending queue.
                runner.Continue(closure, null);
            }
            else
            {
                runner.Continue(closure, next);
            }
        }