コード例 #1
0
ファイル: Handler.cs プロジェクト: mtashkinov/YaccConstructor
        private static void OnParsingFinished(object sender, CommonInterfaces.ParsingFinishedArgs args)
        {
            string lang = args.Lang;

            if (!parsedSppf.ContainsKey(lang))
                parsedSppf.Add(lang, 0);
            else
                parsedSppf[lang]++;

            Action action =
                () =>
                {
                    var isEnd = false;
                    while (!isEnd)
                    {
                        Tuple<ITreeNode, bool> res = YcProcessor.GetNextTree(lang, parsedSppf[lang]);
                        ExistingTreeNodes.AddTree(res.Item1);
                        isEnd = res.Item2;
                    }
                };

            using (TaskBarrier fibers = Process.DaemonProcess.CreateFibers())
            {
                fibers.EnqueueJob(action);
            }
        }
コード例 #2
0
ファイル: Handler.cs プロジェクト: mtashkinov/YaccConstructor
        /// <summary>
        /// Do highlighting some tokens chunk.
        /// </summary>
        /// <param name="sender">Now always null</param>
        /// <param name="args"></param>
        private static void OnLexingFinished(object sender, CommonInterfaces.LexingFinishedArgs<ITreeNode> args)
        {
            IHighlightingConsumer consumer = Process.Consumer;
            var processor = new TreeNodeProcessor(consumer, Process.CSharpFile);

            string xmlPath = YcProcessor.XmlPath(args.Lang);
            ColorHelper.ParseFile(xmlPath, args.Lang);

            Action action =
                () => args.Tokens.ForEach(node => processor.ProcessAfterInterior(node));

            using (TaskBarrier fibers = Process.DaemonProcess.CreateFibers())
            {
                fibers.EnqueueJob(action);
            }

            Process.DoHighlighting(new DaemonStageResult(consumer.Highlightings));
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: afonsomota/ProjectoPADI
        public void ServerDown(CommonInterfaces.Node server)
        {
            int j = 1;
               if (!ctx.ListServer.Contains(server)) return;
               ctx.ListServer.Remove(server);
               for (int i = 0; i < ctx.Location.Count; i++)
               {
               if (ctx.Location[i].IP[0].Port == server.Port || ctx.Location[i].IP[1].Port == server.Port)
               {

                   Node nodeToRemove = null;
                  if (j == 1)
                  {
                       ctx.semiTablemin1 = ctx.Location[i].min;
                       ctx.semiTablemax1 = ctx.Location[i].max;
                       j = 2;
                   }
                   else if (j == 2)
                   {
                       ctx.semiTablemin2 = ctx.Location[i].min;
                       ctx.semiTablemax2 = ctx.Location[i].max;
                       j = 1;
                   }
                  foreach (Node n in ctx.Location[i].IP)
                      if (n.IP == server.IP && n.Port == server.Port)
                          nodeToRemove = n;
                  ctx.Location[i].IP.Remove(nodeToRemove);
               }

               }

               ctx.miss = true;
               Console.WriteLine("min1 - " + ctx.semiTablemin1 + " max1 - " + ctx.semiTablemax1);
               Console.WriteLine("min2 - " + ctx.semiTablemin2 + " max2 - " + ctx.semiTablemax2);
               ctx.Send(ctx.ListClient, ctx.ListServer);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: afonsomota/ProjectoPADI
        public void RegisterServer(CommonInterfaces.Node node)
        {
            Console.WriteLine("Registred" + node.IP + "on port" + node.Port);

            foreach (TransactionContext tc in listTransactionContext)
                if (tc.State != TransactionContext.states.aborted && tc.State != TransactionContext.states.commited)
                {
                    listOfServersStanby.Add(node);
                    return;
                }
            ctx.InsertServer(node);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: afonsomota/ProjectoPADI
        public bool RegisterClient(CommonInterfaces.Node node)
        {
            Console.WriteLine("Registred " + node.IP + " on port " + node.Port);
            if (ctx.ListClient.Contains(node))
            {
                return false;
            }

            lock (ctx.nodesListLocker)
            {
                ctx.Client = node;
            }
            ctx.Send(ctx.ListClient, ctx.ListServer);
            return true;
        }