コード例 #1
0
        protected override bool Run()
        {
            while (frame < values.GetLength(0))
            {
                while (name < values.GetLength(1))
                {
                    // If we have reached the end of a list of names for the current frame, then we have an answer!
                    if (name == values.GetLength(1) - 1)
                    {
                        result = values[frame, name];
                        return(true);
                    }

                    // If this is not a frame, but there are still more names, then this is an error.
                    if (!(values[frame, name] is Frame))
                    {
                        master.ReportLookupError(this);
                    }

                    got_value = false;
                    delayed   = false;
                    // Otherwise, try to get the current value for the current name
                    if (!((Frame)values[frame, name]).GetOrSubscribe(names[name], ConsumeResult))
                    {
                        // The value isn't yet computed. Signal our callback that we want to be slotted.
                        delayed = true;
                        return(false);
                    }
                    // If we got nothing, then it doesn't exist in the current frame. Try the next.
                    if (!got_value)
                    {
                        name = 0;
                        frame++;
                        break;
                    }
                }
            }
            // The name is undefined.
            master.ReportLookupError(this);
            return(false);
        }
コード例 #2
0
 protected override bool Run()
 {
     while (frame_index < frames.Length)
     {
         int index        = frame_index++;
         var root_attempt = new Attempt(this, 0, index, frames[index]);
         known_attempts.AddLast(root_attempt);
         if (frames[index].GetOrSubscribe(names[0], root_attempt.Consume))
         {
             return(false);
         }
     }
     master.ReportLookupError(this, null);
     return(false);
 }